summaryrefslogtreecommitdiffstats
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
commiteeb2bda2fa932045e182879c42baf8954c25c72b (patch)
tree4a9a8d4296a127859df629d703ed3c0873c720eb
parent17acad625cea650b0c8bbdb8f054d5bf1108cd10 (diff)
downloadbcm5719-llvm-eeb2bda2fa932045e182879c42baf8954c25c72b.tar.gz
bcm5719-llvm-eeb2bda2fa932045e182879c42baf8954c25c72b.zip
add a trivial fold
llvm-svn: 23764
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 5b1d10335cf..69478e3b846 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/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(),
OpenPOWER on IntegriCloud