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

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 16 18:07:23 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.43 -> 1.44
---
Log message:

add a trivial fold


---
Diffs of the changes:  (+4 -0)

 DAGCombiner.cpp |    4 ++++
 1 files changed, 4 insertions(+)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.43 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.44
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.43	Sat Oct 15 17:35:40 2005
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp	Sun Oct 16 20:07:11 2005
@@ -532,6 +532,10 @@
   ConstantSDNode *N0C = dyn_cast<ConstantSDNode>(N0.Val);
   ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.Val);
   
+  // fold (sub x, x) -> 0
+  if (N0 == N1)
+    return DAG.getConstant(0, N->getValueType(0));
+  
   // fold (sub c1, c2) -> c1-c2
   if (N0C && N1C)
     return DAG.getConstant(N0C->getValue() - N1C->getValue(),






More information about the llvm-commits mailing list