aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-17 01:07:11 +0000
committerChris Lattner <sabre@nondot.org>2005-10-17 01:07:11 +0000
commit854077d3a5a42c3286f22fd5f72ee98797ed3d71 (patch)
tree0e847ed3b484e46b6664426bc97516cf03ba1a40 /lib
parent7a025c8b4dedee6856d9f118386ef0296eddece0 (diff)
downloadexternal_llvm-854077d3a5a42c3286f22fd5f72ee98797ed3d71.zip
external_llvm-854077d3a5a42c3286f22fd5f72ee98797ed3d71.tar.gz
external_llvm-854077d3a5a42c3286f22fd5f72ee98797ed3d71.tar.bz2
add a trivial fold
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23764 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 5b1d103..69478e3 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -532,6 +532,10 @@ SDOperand DAGCombiner::visitSUB(SDNode *N) {
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(),