Skip to content

Commit 0019c2f

Browse files
committed
[SelectionDAG] Don't crash when freezing illegal float types
1 parent 0c24adc commit 0019c2f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,7 @@ void DAGTypeLegalizer::SoftPromoteHalfResult(SDNode *N, unsigned ResNo) {
24562456
case ISD::FLOG10:
24572457
case ISD::FNEARBYINT:
24582458
case ISD::FNEG:
2459+
case ISD::FREEZE:
24592460
case ISD::FRINT:
24602461
case ISD::FROUND:
24612462
case ISD::FSIN:

llvm/test/CodeGen/X86/freeze.ll

+20
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ define float @freeze_float() {
3333
ret float %t1
3434
}
3535

36+
define half @freeze_half() {
37+
; X86ASM-LABEL: freeze_half:
38+
; X86ASM: # %bb.0:
39+
; X86ASM-NEXT: pushq %rax
40+
; X86ASM-NEXT: .cfi_def_cfa_offset 16
41+
; X86ASM-NEXT: xorl %edi, %edi
42+
; X86ASM-NEXT: callq __gnu_h2f_ieee
43+
; X86ASM-NEXT: callq __gnu_f2h_ieee
44+
; X86ASM-NEXT: movzwl %ax, %edi
45+
; X86ASM-NEXT: callq __gnu_h2f_ieee
46+
; X86ASM-NEXT: addss %xmm0, %xmm0
47+
; X86ASM-NEXT: callq __gnu_f2h_ieee
48+
; X86ASM-NEXT: popq %rcx
49+
; X86ASM-NEXT: .cfi_def_cfa_offset 8
50+
; X86ASM-NEXT: retq
51+
%y1 = freeze half undef
52+
%t1 = fadd half %y1, %y1
53+
ret half %t1
54+
}
55+
3656
define <2 x i32> @freeze_ivec() {
3757
; X86ASM-LABEL: freeze_ivec:
3858
; X86ASM: # %bb.0:

0 commit comments

Comments
 (0)