[llvm] r183133 - R600/SI: Handle nodes with glue results correctly SITargetLowering::foldOperands()

Tom Stellard thomas.stellard at amd.com
Mon Jun 3 10:39:50 PDT 2013


Author: tstellar
Date: Mon Jun  3 12:39:50 2013
New Revision: 183133

URL: http://llvm.org/viewvc/llvm-project?rev=183133&view=rev
Log:
R600/SI: Handle nodes with glue results correctly SITargetLowering::foldOperands()

Modified:
    llvm/trunk/lib/Target/R600/SIISelLowering.cpp

Modified: llvm/trunk/lib/Target/R600/SIISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/SIISelLowering.cpp?rev=183133&r1=183132&r2=183133&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/SIISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/R600/SIISelLowering.cpp Mon Jun  3 12:39:50 2013
@@ -700,6 +700,22 @@ SDNode *SITargetLowering::foldOperands(M
   for (unsigned i = NumOps - NumDefs, e = Node->getNumOperands(); i < e; ++i)
     Ops.push_back(Node->getOperand(i));
 
+  // Nodes that have a glue result are not CSE'd by getMachineNode(), so in
+  // this case a brand new node is always be created, even if the operands
+  // are the same as before.  So, manually check if anything has been changed.
+  if (Desc->Opcode == Opcode) {
+    bool Changed = false;
+    for (unsigned i = 0, e = Node->getNumOperands(); i < e; ++i) {
+      if (Ops[i].getNode() != Node->getOperand(i).getNode()) {
+        Changed = true;
+        break;
+      }
+    }
+    if (!Changed) {
+      return Node;
+    }
+  }
+
   // Create a complete new instruction
   return DAG.getMachineNode(Desc->Opcode, SDLoc(Node), Node->getVTList(), Ops);
 }





More information about the llvm-commits mailing list