[llvm-commits] [llvm] r48294 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Duncan Sands baldrick at free.fr
Wed Mar 12 13:30:08 PDT 2008


Author: baldrick
Date: Wed Mar 12 15:30:08 2008
New Revision: 48294

URL: http://llvm.org/viewvc/llvm-project?rev=48294&view=rev
Log:
Don't try to extract an i32 from an f64.  This
getCopyToParts problem was noticed by the new
LegalizeTypes infrastructure.  In order to avoid
this kind of thing in the future I've added a
check that EXTRACT_ELEMENT is only used with
integers.  Once LegalizeTypes is up and running
most likely BUILD_PAIR and EXTRACT_ELEMENT can
be removed, in favour of using apints instead.

Modified:
    llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=48294&r1=48293&r2=48294&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Wed Mar 12 15:30:08 2008
@@ -217,10 +217,10 @@
     /// alignment '1' in other argument pieces.
     CALL,
 
-    // EXTRACT_ELEMENT - This is used to get the first or second (determined by
-    // a Constant, which is required to be operand #1), element of the aggregate
-    // value specified as operand #0.  This is only for use before legalization,
-    // for values that will be broken into multiple registers.
+    // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by
+    // a Constant, which is required to be operand #1) half of the integer value
+    // specified as operand #0.  This is only for use before legalization, for
+    // values that will be broken into multiple registers.
     EXTRACT_ELEMENT,
 
     // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.  Given

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

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Mar 12 15:30:08 2008
@@ -2090,13 +2090,17 @@
     break;
   case ISD::EXTRACT_ELEMENT:
     assert(N2C && (unsigned)N2C->getValue() < 2 && "Bad EXTRACT_ELEMENT!");
-    
+    assert(!MVT::isVector(N1.getValueType()) &&
+           MVT::isInteger(N1.getValueType()) &&
+           !MVT::isVector(VT) && MVT::isInteger(VT) &&
+           "EXTRACT_ELEMENT only applies to integers!");
+
     // EXTRACT_ELEMENT of BUILD_PAIR is often formed while legalize is expanding
     // 64-bit integers into 32-bit parts.  Instead of building the extract of
     // the BUILD_PAIR, only to have legalize rip it apart, just do it now. 
     if (N1.getOpcode() == ISD::BUILD_PAIR)
       return N1.getOperand(N2C->getValue());
-    
+
     // EXTRACT_ELEMENT of a constant int is also very common.
     if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N1)) {
       unsigned Shift = MVT::getSizeInBits(VT) * N2C->getValue();

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

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Mar 12 15:30:08 2008
@@ -852,19 +852,25 @@
 
     // The number of parts is a power of 2.  Repeatedly bisect the value using
     // EXTRACT_ELEMENT.
-    Parts[0] = Val;
+    Parts[0] = DAG.getNode(ISD::BIT_CONVERT,
+                           MVT::getIntegerType(MVT::getSizeInBits(ValueVT)),
+                           Val);
     for (unsigned StepSize = NumParts; StepSize > 1; StepSize /= 2) {
       for (unsigned i = 0; i < NumParts; i += StepSize) {
         unsigned ThisBits = StepSize * PartBits / 2;
-        MVT::ValueType ThisVT =
-          ThisBits == PartBits ? PartVT : MVT::getIntegerType (ThisBits);
-
-        Parts[i+StepSize/2] =
-          DAG.getNode(ISD::EXTRACT_ELEMENT, ThisVT, Parts[i],
-                      DAG.getConstant(1, PtrVT));
-        Parts[i] =
-          DAG.getNode(ISD::EXTRACT_ELEMENT, ThisVT, Parts[i],
-                      DAG.getConstant(0, PtrVT));
+        MVT::ValueType ThisVT = MVT::getIntegerType (ThisBits);
+        SDOperand &Part0 = Parts[i];
+        SDOperand &Part1 = Parts[i+StepSize/2];
+
+        Part1 = DAG.getNode(ISD::EXTRACT_ELEMENT, ThisVT, Part0,
+                            DAG.getConstant(1, PtrVT));
+        Part0 = DAG.getNode(ISD::EXTRACT_ELEMENT, ThisVT, Part0,
+                            DAG.getConstant(0, PtrVT));
+
+        if (ThisBits == PartBits && ThisVT != PartVT) {
+          Part0 = DAG.getNode(ISD::BIT_CONVERT, PartVT, Part0);
+          Part1 = DAG.getNode(ISD::BIT_CONVERT, PartVT, Part1);
+        }
       }
     }
 





More information about the llvm-commits mailing list