diff options
author | Dale Johannesen <dalej@apple.com> | 2008-12-23 01:59:54 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2008-12-23 01:59:54 +0000 |
commit | 58e39b0200f448b796a89e2b7e9b8a5607a1771a (patch) | |
tree | d2982effe6f9245347cef8f0b84edc5dc564d109 /lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | ae53c932b9f3b6046781aeceadc7559bc477f5d4 (diff) |
One more permutation of subtracting off a base value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61361 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 783bfce9cc..e3525df181 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1184,6 +1184,12 @@ SDValue DAGCombiner::visitSUB(SDNode *N) { N0.getOperand(1).getOperand(0) == N1) return DAG.getNode(ISD::SUB, VT, N0.getOperand(0), N0.getOperand(1).getOperand(1)); + // fold ((A-(B-C))-C) -> A-B + if (N0.getOpcode() == ISD::SUB && + N0.getOperand(1).getOpcode() == ISD::SUB && + N0.getOperand(1).getOperand(1) == N1) + return DAG.getNode(ISD::SUB, VT, N0.getOperand(0), + N0.getOperand(1).getOperand(0)); // fold (sub x, (select cc, 0, c)) -> (select cc, x, (sub, x, c)) if (N1.getOpcode() == ISD::SELECT && N1.getNode()->hasOneUse()) { SDValue Result = combineSelectAndUse(N, N1, N0, DAG, TLI, LegalOperations); |