diff options
| author | Dale Johannesen <dalej@apple.com> | 2008-12-02 01:30:54 +0000 |
|---|---|---|
| committer | Dale Johannesen <dalej@apple.com> | 2008-12-02 01:30:54 +0000 |
| commit | 8c76670b5a03dc5f4904790f08ee820f6b142702 (patch) | |
| tree | ca83eaaae928042f799d3f70e2e20fdb9a3a7ac9 /llvm/lib/CodeGen/SelectionDAG | |
| parent | 817737a00224ff3ddd78e983a531d148fd190aee (diff) | |
| download | bcm5719-llvm-8c76670b5a03dc5f4904790f08ee820f6b142702.tar.gz bcm5719-llvm-8c76670b5a03dc5f4904790f08ee820f6b142702.zip | |
Add a few more transformations.
llvm-svn: 60391
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 6b35126a10e..629e22d11ab 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1013,6 +1013,30 @@ SDValue DAGCombiner::visitADD(SDNode *N) { // fold ((B-A)+A) -> B if (N0.getOpcode() == ISD::SUB && N1 == N0.getOperand(1)) return N0.getOperand(0); + // fold (A+(B-(A+C))) to (B-C) + if (N1.getOpcode() == ISD::SUB && N1.getOperand(1).getOpcode() == ISD::ADD && + N0 == N1.getOperand(1).getOperand(0)) { + return DAG.getNode(ISD::SUB, VT, N1.getOperand(0), + N1.getOperand(1).getOperand(1)); + } + // fold (A+(B-(C+A))) to (B-C) + if (N1.getOpcode() == ISD::SUB && N1.getOperand(1).getOpcode() == ISD::ADD && + N0 == N1.getOperand(1).getOperand(1)) { + return DAG.getNode(ISD::SUB, VT, N1.getOperand(0), + N1.getOperand(1).getOperand(0)); + } + // fold (A-B)+(C-D) to (A+C)-(B+D) when A or C is constant + if (N0.getOpcode() == ISD::SUB && N1.getOpcode() == ISD::SUB) { + SDValue N00 = N0.getOperand(0); + SDValue N01 = N0.getOperand(1); + SDValue N10 = N1.getOperand(0); + SDValue N11 = N1.getOperand(1); + if (isa<ConstantSDNode>(N00) || isa<ConstantSDNode>(N10)) { + return DAG.getNode(ISD::SUB, VT, + DAG.getNode(ISD::ADD, VT, N00, N10), + DAG.getNode(ISD::ADD, VT, N01, N11)); + } + } if (!VT.isVector() && SimplifyDemandedBits(SDValue(N, 0))) return SDValue(N, 0); |

