[llvm-commits] [llvm] r72162 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll test/CodeGen/XCore/fneg.ll

Eli Friedman eli.friedman at gmail.com
Tue May 19 23:02:09 PDT 2009


Author: efriedma
Date: Wed May 20 01:02:09 2009
New Revision: 72162

URL: http://llvm.org/viewvc/llvm-project?rev=72162&view=rev
Log:
Fix for PR4235: to build a floating-point value from integer parts, 
build an integer and cast that to a float.  This fixes a crash 
caused by trying to split an f32 into two f16's.

This changes the behavior in test/CodeGen/XCore/fneg.ll because that 
testcase now triggers a DAGCombine which converts the fneg into an integer
operation.  If someone is interested, it's probably possible to tweak 
the test to generate an actual fneg.


Added:
    llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll
Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
    llvm/trunk/test/CodeGen/XCore/fneg.ll

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=72162&r1=72161&r2=72162&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Wed May 20 01:02:09 2009
@@ -426,7 +426,7 @@
 
   if (NumParts > 1) {
     // Assemble the value from multiple parts.
-    if (!ValueVT.isVector()) {
+    if (!ValueVT.isVector() && ValueVT.isInteger()) {
       unsigned PartBits = PartVT.getSizeInBits();
       unsigned ValueBits = ValueVT.getSizeInBits();
 
@@ -438,9 +438,7 @@
         ValueVT : MVT::getIntegerVT(RoundBits);
       SDValue Lo, Hi;
 
-      MVT HalfVT = ValueVT.isInteger() ?
-        MVT::getIntegerVT(RoundBits/2) :
-        MVT::getFloatingPointVT(RoundBits/2);
+      MVT HalfVT = MVT::getIntegerVT(RoundBits/2);
 
       if (RoundParts > 2) {
         Lo = getCopyFromParts(DAG, dl, Parts, RoundParts/2, PartVT, HalfVT);
@@ -473,7 +471,7 @@
         Lo = DAG.getNode(ISD::ZERO_EXTEND, dl, TotalVT, Lo);
         Val = DAG.getNode(ISD::OR, dl, TotalVT, Lo, Hi);
       }
-    } else {
+    } else if (ValueVT.isVector()) {
       // Handle a multi-element vector.
       MVT IntermediateVT, RegisterVT;
       unsigned NumIntermediates;
@@ -510,6 +508,22 @@
       Val = DAG.getNode(IntermediateVT.isVector() ?
                         ISD::CONCAT_VECTORS : ISD::BUILD_VECTOR, dl,
                         ValueVT, &Ops[0], NumIntermediates);
+    } else if (PartVT.isFloatingPoint()) {
+      // FP split into multiple FP parts (for ppcf128)
+      assert(ValueVT == MVT(MVT::ppcf128) && PartVT == MVT(MVT::f64) &&
+             "Unexpected split");
+      SDValue Lo, Hi;
+      Lo = DAG.getNode(ISD::BIT_CONVERT, dl, MVT(MVT::f64), Parts[0]);
+      Hi = DAG.getNode(ISD::BIT_CONVERT, dl, MVT(MVT::f64), Parts[1]);
+      if (TLI.isBigEndian())
+        std::swap(Lo, Hi);
+      Val = DAG.getNode(ISD::BUILD_PAIR, dl, ValueVT, Lo, Hi);
+    } else {
+      // FP split into integer parts (soft fp)
+      assert(ValueVT.isFloatingPoint() && PartVT.isInteger() &&
+             !PartVT.isVector() && "Unexpected split");
+      MVT IntVT = MVT::getIntegerVT(ValueVT.getSizeInBits());
+      Val = getCopyFromParts(DAG, dl, Parts, NumParts, PartVT, IntVT);
     }
   }
 

Added: llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll?rev=72162&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll (added)
+++ llvm/trunk/test/CodeGen/MSP430/2009-05-19-DoubleSplit.ll Wed May 20 01:02:09 2009
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | llc -march=msp430
+
+define i16 @test(double %d) nounwind {
+entry:
+        %add = add double %d, 1.000000e+00
+        %call = tail call i16 @funct(double %add) nounwind
+        ret i16 %call
+}
+
+declare i16 @funct(double)
+

Modified: llvm/trunk/test/CodeGen/XCore/fneg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/fneg.ll?rev=72162&r1=72161&r2=72162&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/XCore/fneg.ll (original)
+++ llvm/trunk/test/CodeGen/XCore/fneg.ll Wed May 20 01:02:09 2009
@@ -1,5 +1,5 @@
 ; RUN: llvm-as < %s | llc -march=xcore > %t1.s
-; RUN: grep "bl __subdf3" %t1.s | count 1
+; RUN: grep "xor" %t1.s | count 1
 define i1 @test(double %F) nounwind {
 entry:
 	%0 = sub double -0.000000e+00, %F





More information about the llvm-commits mailing list