[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Oct 10 23:07:27 PDT 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.30 -> 1.31
---
Log message:
Add a canonicalization that got lost, fixing PowerPC/fold-li.ll:SUB
---
Diffs of the changes: (+5 -3)
DAGCombiner.cpp | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.30 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.31
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.30 Mon Oct 10 18:00:08 2005
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Oct 11 01:07:15 2005
@@ -517,9 +517,11 @@
if (N0C && N1C)
return DAG.getConstant(N0C->getValue() - N1C->getValue(),
N->getValueType(0));
- // fold (sub x, 0) -> x
- if (N1C && N1C->isNullValue())
- return N0;
+ // fold (sub x, c) -> (add x, -c)
+ if (N1C)
+ return DAG.getNode(ISD::ADD, N0.getValueType(), N0,
+ DAG.getConstant(-N1C->getValue(), N0.getValueType()));
+
// fold (A+B)-A -> B
if (N0.getOpcode() == ISD::ADD && N0.getOperand(0) == N1)
return N0.getOperand(1);
More information about the llvm-commits
mailing list