[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Jan 7 14:29:02 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.8 -> 1.9
---
Log message:

Fix a bug in load expansion legalization and ret legalization.  This fixes
CodeGen/Generic/select.ll:castconst.


---
Diffs of the changes:  (+17 -9)

Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.8 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.9
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.8	Fri Jan  7 16:12:08 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Fri Jan  7 16:28:47 2005
@@ -72,6 +72,11 @@
   /// more than once.
   std::map<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedNodes;
 
+  void AddLegalizedOperand(SDOperand From, SDOperand To) {
+    bool isNew = LegalizedNodes.insert(std::make_pair(From, To)).second;
+    assert(isNew && "Got into the map somehow?");
+  }
+
   /// setValueTypeAction - Set the action for a particular value type.  This
   /// assumes an action has not already been set for this value type.
   void setValueTypeAction(MVT::ValueType VT, LegalizeAction A) {
@@ -323,7 +328,14 @@
     if (Tmp1 != Node->getOperand(0) ||
         Tmp2 != Node->getOperand(1))
       Result = DAG.getLoad(Node->getValueType(0), Tmp1, Tmp2);
-    break;
+    else
+      Result = SDOperand(Node, 0);
+    
+    // Since loads produce two values, make sure to remember that we legalized
+    // both of them.
+    AddLegalizedOperand(SDOperand(Node, 0), Result);
+    AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
+    return Result.getValue(Op.ResNo);
 
   case ISD::EXTRACT_ELEMENT:
     // Get both the low and high parts.
@@ -368,7 +380,7 @@
       switch (getTypeAction(Node->getOperand(1).getValueType())) {
       case Legal:
         Tmp2 = LegalizeOp(Node->getOperand(1));
-        if (Tmp2 != Node->getOperand(1))
+        if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1))
           Result = DAG.getNode(ISD::RET, MVT::Other, Tmp1, Tmp2);
         break;
       case Expand: {
@@ -550,10 +562,8 @@
     break;
   }
 
-  if (!Op.Val->hasOneUse()) {
-    bool isNew = LegalizedNodes.insert(std::make_pair(Op, Result)).second;
-    assert(isNew && "Got into the map somehow?");
-  }
+  if (!Op.Val->hasOneUse())
+    AddLegalizedOperand(Op, Result);
 
   return Result;
 }
@@ -632,9 +642,7 @@
     Hi = DAG.getLoad(NVT, Lo.getValue(1), Ptr);
     
     // Remember that we legalized the chain.
-    bool isNew = LegalizedNodes.insert(std::make_pair(Op.getValue(1),
-                                                      Hi.getValue(1))).second;
-    assert(isNew && "This node was already legalized!");
+    AddLegalizedOperand(Op.getValue(1), Hi.getValue(1));
     if (!TLI.isLittleEndian())
       std::swap(Lo, Hi);
     break;






More information about the llvm-commits mailing list