[PATCH] [SelectionDAG] Fixed issue with uitofp vector constant folding being treated as sitofp

Simon Pilgrim llvm-dev at redking.me.uk
Mon Mar 23 15:47:40 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8560

Files:
  llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/trunk/test/CodeGen/X86/x86-setcc-int-to-fp-combine.ll

Index: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2837,13 +2837,11 @@
         break;
       case ISD::UINT_TO_FP:
       case ISD::SINT_TO_FP: {
+        // Let the above scalar folding handle the folding of each element.
         SmallVector<SDValue, 8> Ops;
         for (int i = 0, e = VT.getVectorNumElements(); i != e; ++i) {
           SDValue OpN = BV->getOperand(i);
-          // Let the above scalar folding handle the conversion of each
-          // element.
-          OpN = getNode(ISD::SINT_TO_FP, DL, VT.getVectorElementType(),
-                        OpN);
+          OpN = getNode(Opcode, DL, VT.getVectorElementType(), OpN);
           Ops.push_back(OpN);
         }
         return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
Index: llvm/trunk/test/CodeGen/X86/x86-setcc-int-to-fp-combine.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/x86-setcc-int-to-fp-combine.ll
+++ llvm/trunk/test/CodeGen/X86/x86-setcc-int-to-fp-combine.ll
@@ -72,3 +72,18 @@
   %result = sitofp <4 x i32> %and to <4 x float>
   ret <4 x float> %result
 }
+
+; Test the general purpose constant folding of uint->fp.
+define void @foo4(<4 x float>* noalias %result) nounwind {
+; CHECK-LABEL: LCPI4_0:
+; CHECK-NEXT: .long 1065353216              ## float 1.000000e+00
+; CHECK-NEXT: .long 1123942400              ## float 1.270000e+02
+; CHECK-NEXT: .long 1124073472              ## float 1.280000e+02
+; CHECK-NEXT: .long 1132396544              ## float 2.550000e+02
+; CHECK-LABEL: foo4:
+; CHECK:  movaps LCPI4_0(%rip), %xmm0
+
+  %val = uitofp <4 x i8> <i8 1, i8 127, i8 -128, i8 -1> to <4 x float>
+  store <4 x float> %val, <4 x float>* %result
+  ret void
+}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8560.22527.patch
Type: text/x-patch
Size: 1911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150323/2272f282/attachment.bin>


More information about the llvm-commits mailing list