[llvm-commits] [llvm] r37843 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Dan Gohman djg at cray.com
Fri Jul 6 06:10:57 PDT 2007


Hi Evan,

Ok, I believe I've figured out where I was confused. The attached
patch makes the endian-swapping always done, even for virtual
registers, which appears to be the right thing to do, makes the
code simpler, and it fixes the problem you pointed out with
SingleSource/UnitTests/2005-05-12-Int64ToFP.c

Dan

On Thu, Jul 05, 2007 at 06:48:31PM -0700, Evan Cheng wrote:
> Hi Dan,
> 
> I've committed this:
> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of- 
> Mon-20070702/051079.html
> 
> as a workaround. Please figure out a proper fix. Thanks!
> 
> Evan
> 

-- 
Dan Gohman, Cray Inc.
-------------- next part --------------
Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	(revision 37935)
+++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	(working copy)
@@ -621,7 +621,6 @@
                                   unsigned NumParts,
                                   MVT::ValueType PartVT,
                                   MVT::ValueType ValueVT,
-                                  bool EndianOrder,
                                   ISD::NodeType AssertOp = ISD::DELETED_NODE) {
   if (!MVT::isVector(ValueVT) || NumParts == 1) {
     SDOperand Val = Parts[0];
@@ -631,7 +630,7 @@
       assert(NumParts == 2 &&
              "Cannot expand to more than 2 elts yet!");
       SDOperand Hi = Parts[1];
-      if (EndianOrder && !DAG.getTargetLoweringInfo().isLittleEndian())
+      if (!DAG.getTargetLoweringInfo().isLittleEndian())
         std::swap(Val, Hi);
       return DAG.getNode(ISD::BUILD_PAIR, ValueVT, Val, Hi);
     }
@@ -692,7 +691,7 @@
     // as appropriate.
     for (unsigned i = 0; i != NumParts; ++i)
       Ops[i] = getCopyFromParts(DAG, &Parts[i], 1,
-                                PartVT, IntermediateVT, EndianOrder);
+                                PartVT, IntermediateVT);
   } else if (NumParts > 0) {
     // If the intermediate type was expanded, build the intermediate operands
     // from the parts.
@@ -701,7 +700,7 @@
     unsigned Factor = NumIntermediates / NumParts;
     for (unsigned i = 0; i != NumIntermediates; ++i)
       Ops[i] = getCopyFromParts(DAG, &Parts[i * Factor], Factor,
-                                PartVT, IntermediateVT, EndianOrder);
+                                PartVT, IntermediateVT);
   }
   
   // Build a vector with BUILD_VECTOR or CONCAT_VECTORS from the intermediate
@@ -718,8 +717,7 @@
                            SDOperand Val,
                            SDOperand *Parts,
                            unsigned NumParts,
-                           MVT::ValueType PartVT,
-                           bool EndianOrder) {
+                           MVT::ValueType PartVT) {
   MVT::ValueType ValueVT = Val.getValueType();
 
   if (!MVT::isVector(ValueVT) || NumParts == 1) {
@@ -728,7 +726,7 @@
       for (unsigned i = 0; i != NumParts; ++i)
         Parts[i] = DAG.getNode(ISD::EXTRACT_ELEMENT, PartVT, Val,
                                DAG.getConstant(i, MVT::i32));
-      if (EndianOrder && !DAG.getTargetLoweringInfo().isLittleEndian())
+      if (!DAG.getTargetLoweringInfo().isLittleEndian())
         std::reverse(Parts, Parts + NumParts);
       return;
     }
@@ -789,7 +787,7 @@
     // If the register was not expanded, promote or copy the value,
     // as appropriate.
     for (unsigned i = 0; i != NumParts; ++i)
-      getCopyToParts(DAG, Ops[i], &Parts[i], 1, PartVT, EndianOrder);
+      getCopyToParts(DAG, Ops[i], &Parts[i], 1, PartVT);
   } else if (NumParts > 0) {
     // If the intermediate type was expanded, split each the value into
     // legal parts.
@@ -797,7 +795,7 @@
            "Must expand into a divisible number of parts!");
     unsigned Factor = NumParts / NumIntermediates;
     for (unsigned i = 0; i != NumIntermediates; ++i)
-      getCopyToParts(DAG, Ops[i], &Parts[i * Factor], Factor, PartVT, EndianOrder);
+      getCopyToParts(DAG, Ops[i], &Parts[i * Factor], Factor, PartVT);
   }
 }
 
@@ -928,7 +926,7 @@
       unsigned NumParts = TLI.getNumRegisters(VT);
       MVT::ValueType PartVT = TLI.getRegisterType(VT);
       SmallVector<SDOperand, 4> Parts(NumParts);
-      getCopyToParts(DAG, RetOp, &Parts[0], NumParts, PartVT, true);
+      getCopyToParts(DAG, RetOp, &Parts[0], NumParts, PartVT);
       for (unsigned i = 0; i < NumParts; ++i) {
         NewValues.push_back(Parts[i]);
         NewValues.push_back(DAG.getConstant(false, MVT::i32));
@@ -2984,11 +2982,6 @@
 /// If the Flag pointer is NULL, no flag is used.
 SDOperand RegsForValue::getCopyFromRegs(SelectionDAG &DAG,
                                         SDOperand &Chain, SDOperand *Flag)const{
-  // Get the list of registers, in the appropriate order.
-  std::vector<unsigned> R(Regs);
-  if (!DAG.getTargetLoweringInfo().isLittleEndian())
-    std::reverse(R.begin(), R.end());
-
   // Copy the legal parts from the registers.
   unsigned NumParts = Regs.size();
   SmallVector<SDOperand, 8> Parts(NumParts);
@@ -3003,7 +2996,7 @@
   }
   
   // Assemble the legal parts into the final value.
-  return getCopyFromParts(DAG, &Parts[0], NumParts, RegVT, ValueVT, false);
+  return getCopyFromParts(DAG, &Parts[0], NumParts, RegVT, ValueVT);
 }
 
 /// getCopyToRegs - Emit a series of CopyToReg nodes that copies the
@@ -3012,21 +3005,16 @@
 /// If the Flag pointer is NULL, no flag is used.
 void RegsForValue::getCopyToRegs(SDOperand Val, SelectionDAG &DAG,
                                  SDOperand &Chain, SDOperand *Flag) const {
-  // Get the list of registers, in the appropriate order.
-  std::vector<unsigned> R(Regs);
-  if (!DAG.getTargetLoweringInfo().isLittleEndian())
-    std::reverse(R.begin(), R.end());
-
   // Get the list of the values's legal parts.
   unsigned NumParts = Regs.size();
   SmallVector<SDOperand, 8> Parts(NumParts);
-  getCopyToParts(DAG, Val, &Parts[0], NumParts, RegVT, false);
+  getCopyToParts(DAG, Val, &Parts[0], NumParts, RegVT);
 
   // Copy the parts into the registers.
   for (unsigned i = 0; i != NumParts; ++i) {
     SDOperand Part = Flag ?
-                     DAG.getCopyToReg(Chain, R[i], Parts[i], *Flag) :
-                     DAG.getCopyToReg(Chain, R[i], Parts[i]);
+                     DAG.getCopyToReg(Chain, Regs[i], Parts[i], *Flag) :
+                     DAG.getCopyToReg(Chain, Regs[i], Parts[i]);
     Chain = Part.getValue(0);
     if (Flag)
       *Flag = Part.getValue(1);
@@ -3897,7 +3885,7 @@
       SmallVector<SDOperand, 4> Parts(NumParts);
       for (unsigned j = 0; j != NumParts; ++j)
         Parts[j] = SDOperand(Result, i++);
-      Ops.push_back(getCopyFromParts(DAG, &Parts[0], NumParts, PartVT, VT, true));
+      Ops.push_back(getCopyFromParts(DAG, &Parts[0], NumParts, PartVT, VT));
       break;
     }
     }
@@ -3969,7 +3957,7 @@
       MVT::ValueType PartVT = getRegisterType(VT);
       unsigned NumParts = getNumRegisters(VT);
       SmallVector<SDOperand, 4> Parts(NumParts);
-      getCopyToParts(DAG, Op, &Parts[0], NumParts, PartVT, true);
+      getCopyToParts(DAG, Op, &Parts[0], NumParts, PartVT);
       for (unsigned i = 0; i != NumParts; ++i) {
         // if it isn't first piece, alignment must be 1
         unsigned MyFlags = Flags;
@@ -4009,7 +3997,7 @@
     SmallVector<SDOperand, 4> Results(NumRegs);
     for (unsigned i = 0; i != NumRegs; ++i)
       Results[i] = Res.getValue(i);
-    Res = getCopyFromParts(DAG, &Results[0], NumRegs, RegisterVT, VT, false, AssertOp);
+    Res = getCopyFromParts(DAG, &Results[0], NumRegs, RegisterVT, VT, AssertOp);
   }
 
   return std::make_pair(Res, Chain);
@@ -4299,7 +4287,7 @@
   SmallVector<SDOperand, 8> Chains(NumRegs);
 
   // Copy the value by legal parts into sequential virtual registers.
-  getCopyToParts(DAG, Op, &Regs[0], NumRegs, RegisterVT, false);
+  getCopyToParts(DAG, Op, &Regs[0], NumRegs, RegisterVT);
   for (unsigned i = 0; i != NumRegs; ++i)
     Chains[i] = DAG.getCopyToReg(getRoot(), Reg + i, Regs[i]);
   return DAG.getNode(ISD::TokenFactor, MVT::Other, &Chains[0], NumRegs);
@@ -4436,8 +4424,8 @@
   if (TI->getNumSuccessors())
     SuccsHandled.resize(BB->getParent()->getNumBlockIDs());
     
-  // Check successor nodes PHI nodes that expect a constant to be available from
-  // this block.
+  // Check successor nodes' PHI nodes that expect a constant to be available
+  // from this block.
   for (unsigned succ = 0, e = TI->getNumSuccessors(); succ != e; ++succ) {
     BasicBlock *SuccBB = TI->getSuccessor(succ);
     if (!isa<PHINode>(SuccBB->begin())) continue;


More information about the llvm-commits mailing list