diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-01-12 20:22:43 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-01-12 20:22:43 +0000 |
| commit | 3470b5dee6ca7dd1165189ef8a5d04248d4eddbf (patch) | |
| tree | 3e80222e86dfd3b0a79fe6ed8901a396446184bf /llvm/lib/CodeGen | |
| parent | c993d4522d98ecd967f4e6e75cc103ab4e3e8579 (diff) | |
| download | bcm5719-llvm-3470b5dee6ca7dd1165189ef8a5d04248d4eddbf.tar.gz bcm5719-llvm-3470b5dee6ca7dd1165189ef8a5d04248d4eddbf.zip | |
Add a simple missing fold to produce this:
subfic r3, r2, 33
instead of this:
subfic r2, r2, 32
addi r3, r2, 1
llvm-svn: 25255
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index cb80e250380..9203c81f557 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -696,6 +696,14 @@ SDOperand DAGCombiner::visitADD(SDNode *N) { return DAG.getNode(ISD::ADD, VT, N0.getOperand(0), DAG.getConstant(N1C->getValue()+N01C->getValue(), VT)); } + + // fold ((c1-A)+c2) -> (c1+c2)-A + if (N1C && N0.getOpcode() == ISD::SUB) + if (ConstantSDNode *N0C = dyn_cast<ConstantSDNode>(N0.getOperand(0))) + return DAG.getNode(ISD::SUB, VT, + DAG.getConstant(N1C->getValue()+N0C->getValue(), VT), + N0.getOperand(1)); + // fold ((0-A) + B) -> B-A if (N0.getOpcode() == ISD::SUB && isa<ConstantSDNode>(N0.getOperand(0)) && cast<ConstantSDNode>(N0.getOperand(0))->isNullValue()) |

