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

Chris Lattner lattner at cs.uiuc.edu
Thu Aug 25 12:12:22 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.165 -> 1.166
---
Log message:

Don't auto-cse nodes that return flags


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

 SelectionDAG.cpp |   55 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 17 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.165 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.166
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.165	Thu Aug 25 12:54:58 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Thu Aug 25 14:12:10 2005
@@ -1021,9 +1021,14 @@
     break;
   }
 
-  SDNode *&N = UnaryOps[std::make_pair(Opcode, std::make_pair(Operand, VT))];
-  if (N) return SDOperand(N, 0);
-  N = new SDNode(Opcode, Operand);
+  SDNode *N;
+  if (VT != MVT::Flag) { // Don't CSE flag producing nodes
+    SDNode *&E = UnaryOps[std::make_pair(Opcode, std::make_pair(Operand, VT))];
+    if (E) return SDOperand(N, 0);
+    E = N = new SDNode(Opcode, Operand);
+  } else {
+    N = new SDNode(Opcode, Operand);
+  }
   N->setValueTypes(VT);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1582,7 +1587,8 @@
 
   // Memoize this node if possible.
   SDNode *N;
-  if (Opcode != ISD::CALLSEQ_START && Opcode != ISD::CALLSEQ_END) {
+  if (Opcode != ISD::CALLSEQ_START && Opcode != ISD::CALLSEQ_END &&
+      VT != MVT::Flag) {
     SDNode *&BON = BinaryOps[std::make_pair(Opcode, std::make_pair(N1, N2))];
     if (BON) return SDOperand(BON, 0);
 
@@ -1704,11 +1710,15 @@
   Ops.push_back(N2);
   Ops.push_back(N3);
 
-  // Memoize nodes.
-  SDNode *&N = OneResultNodes[std::make_pair(Opcode, std::make_pair(VT, Ops))];
-  if (N) return SDOperand(N, 0);
-
-  N = new SDNode(Opcode, N1, N2, N3);
+  // Memoize node if it doesn't produce a flag.
+  SDNode *N;
+  if (VT != MVT::Flag) {
+    SDNode *&E = OneResultNodes[std::make_pair(Opcode,std::make_pair(VT, Ops))];
+    if (E) return SDOperand(E, 0);
+    E = N = new SDNode(Opcode, N1, N2, N3);
+  } else {
+    N = new SDNode(Opcode, N1, N2, N3);
+  }
   N->setValueTypes(VT);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1833,9 +1843,15 @@
   }
 
   // Memoize nodes.
-  SDNode *&N = OneResultNodes[std::make_pair(Opcode, std::make_pair(VT, Ops))];
-  if (N) return SDOperand(N, 0);
-  N = new SDNode(Opcode, Ops);
+  SDNode *N;
+  if (VT != MVT::Flag) {
+    SDNode *&E =
+      OneResultNodes[std::make_pair(Opcode, std::make_pair(VT, Ops))];
+    if (E) return SDOperand(E, 0);
+    E = N = new SDNode(Opcode, Ops);
+  } else {
+    N = new SDNode(Opcode, Ops);
+  }
   N->setValueTypes(VT);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
@@ -1888,11 +1904,16 @@
 #endif
   }
 
-  // Memoize the node.
-  SDNode *&N = ArbitraryNodes[std::make_pair(Opcode, std::make_pair(ResultTys,
-                                                                    Ops))];
-  if (N) return SDOperand(N, 0);
-  N = new SDNode(Opcode, Ops);
+  // Memoize the node unless it returns a flag.
+  SDNode *N;
+  if (ResultTys.back() != MVT::Flag) {
+    SDNode *&E =
+      ArbitraryNodes[std::make_pair(Opcode, std::make_pair(ResultTys, Ops))];
+    if (E) return SDOperand(E, 0);
+    E = N = new SDNode(Opcode, Ops);
+  } else {
+    N = new SDNode(Opcode, Ops);
+  }
   N->setValueTypes(ResultTys);
   AllNodes.push_back(N);
   return SDOperand(N, 0);






More information about the llvm-commits mailing list