From 854077d3a5a42c3286f22fd5f72ee98797ed3d71 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 17 Oct 2005 01:07:11 +0000 Subject: add a trivial fold git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23764 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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(N0.Val); ConstantSDNode *N1C = dyn_cast(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(), -- cgit v1.1