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

Chris Lattner lattner at cs.uiuc.edu
Sat Jan 14 14:41:58 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.263 -> 1.264
---
Log message:

Token chain results are not always the first or last result.  Consider copyfromreg nodes, where they are the middle result (the flag result is last)


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

 LegalizeDAG.cpp |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.263 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.264
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.263	Fri Jan 13 21:14:10 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Sat Jan 14 16:41:46 2006
@@ -3016,6 +3016,7 @@
     Tmp2 = LegalizeOp(Node->getOperand(1));
     Result = DAG.getNode(ISD::SRL, NVT, Tmp1, Tmp2);
     break;
+    
   case ISD::LOAD:
     Tmp1 = LegalizeOp(Node->getOperand(0));   // Legalize the chain.
     Tmp2 = LegalizeOp(Node->getOperand(1));   // Legalize the pointer.
@@ -3374,11 +3375,24 @@
   if (Node->use_empty())
     return 0;   // No CallSeqEnd
 
+  // The chain is usually at the end.
   SDOperand TheChain(Node, Node->getNumValues()-1);
-  if (TheChain.getValueType() != MVT::Other)
+  if (TheChain.getValueType() != MVT::Other) {
+    // Sometimes it's at the beginning.
     TheChain = SDOperand(Node, 0);
-  if (TheChain.getValueType() != MVT::Other)
-    return 0;
+    if (TheChain.getValueType() != MVT::Other) {
+      // Otherwise, hunt for it.
+      for (unsigned i = 1, e = Node->getNumValues(); i != e; ++i)
+        if (Node->getValueType(i) == MVT::Other) {
+          TheChain = SDOperand(Node, i);
+          break;
+        }
+
+      // Otherwise, we walked into a node without a chain.  
+      if (TheChain.getValueType() != MVT::Other)
+        return 0;
+    }
+  }
 
   for (SDNode::use_iterator UI = Node->use_begin(),
          E = Node->use_end(); UI != E; ++UI) {






More information about the llvm-commits mailing list