[llvm] 0019c2f - [SelectionDAG] Don't crash when freezing illegal float types

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 11:45:36 PDT 2020


Author: Benjamin Kramer
Date: 2020-03-24T19:45:19+01:00
New Revision: 0019c2f194a5e1f4cd65c5284e204328cc40ab3d

URL: https://github.com/llvm/llvm-project/commit/0019c2f194a5e1f4cd65c5284e204328cc40ab3d
DIFF: https://github.com/llvm/llvm-project/commit/0019c2f194a5e1f4cd65c5284e204328cc40ab3d.diff

LOG: [SelectionDAG] Don't crash when freezing illegal float types

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
    llvm/test/CodeGen/X86/freeze.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 428dc83e2fd3..60174fc9da8f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -2456,6 +2456,7 @@ void DAGTypeLegalizer::SoftPromoteHalfResult(SDNode *N, unsigned ResNo) {
   case ISD::FLOG10:
   case ISD::FNEARBYINT:
   case ISD::FNEG:
+  case ISD::FREEZE:
   case ISD::FRINT:
   case ISD::FROUND:
   case ISD::FSIN:

diff  --git a/llvm/test/CodeGen/X86/freeze.ll b/llvm/test/CodeGen/X86/freeze.ll
index 9ae9661a148c..07f9faabf68c 100644
--- a/llvm/test/CodeGen/X86/freeze.ll
+++ b/llvm/test/CodeGen/X86/freeze.ll
@@ -33,6 +33,26 @@ define float @freeze_float() {
   ret float %t1
 }
 
+define half @freeze_half() {
+; X86ASM-LABEL: freeze_half:
+; X86ASM:       # %bb.0:
+; X86ASM-NEXT:    pushq %rax
+; X86ASM-NEXT:    .cfi_def_cfa_offset 16
+; X86ASM-NEXT:    xorl %edi, %edi
+; X86ASM-NEXT:    callq __gnu_h2f_ieee
+; X86ASM-NEXT:    callq __gnu_f2h_ieee
+; X86ASM-NEXT:    movzwl %ax, %edi
+; X86ASM-NEXT:    callq __gnu_h2f_ieee
+; X86ASM-NEXT:    addss %xmm0, %xmm0
+; X86ASM-NEXT:    callq __gnu_f2h_ieee
+; X86ASM-NEXT:    popq %rcx
+; X86ASM-NEXT:    .cfi_def_cfa_offset 8
+; X86ASM-NEXT:    retq
+  %y1 = freeze half undef
+  %t1 = fadd half %y1, %y1
+  ret half %t1
+}
+
 define <2 x i32> @freeze_ivec() {
 ; X86ASM-LABEL: freeze_ivec:
 ; X86ASM:       # %bb.0:


        


More information about the llvm-commits mailing list