projects
/
oota-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
04ecf6d
)
Add a canonicalization that got lost, fixing PowerPC/fold-li.ll:SUB
author
Chris Lattner
<sabre@nondot.org>
Tue, 11 Oct 2005 06:07:15 +0000
(06:07 +0000)
committer
Chris Lattner
<sabre@nondot.org>
Tue, 11 Oct 2005 06:07:15 +0000
(06:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23693
91177308
-0d34-0410-b5e6-
96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
patch
|
blob
|
history
diff --git
a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index efeee071f0be22c25c7b44824e1a8e414f45ea1f..0098a56a9a241f67b03555c4f7206b7748aff382 100644
(file)
--- a/
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@
-517,9
+517,11
@@
SDOperand DAGCombiner::visitSUB(SDNode *N) {
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);