diff options
author | Chris Lattner <sabre@nondot.org> | 2005-04-10 04:04:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-04-10 04:04:49 +0000 |
commit | f2bff9241188b59e9ac3d11383d3af5547953565 (patch) | |
tree | a905dbc809a50a65212f1128e791802706fd8b4e /llvm/lib | |
parent | b076731713356cbcb2a72a17ffd3f0aa80444589 (diff) | |
download | bcm5719-llvm-f2bff9241188b59e9ac3d11383d3af5547953565.tar.gz bcm5719-llvm-f2bff9241188b59e9ac3d11383d3af5547953565.zip |
add a simple xform
llvm-svn: 21203
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index f33ecd72239..7cf89144c3b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -892,6 +892,12 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, return getNode(ISD::SUB, VT, N1, N2.getOperand(0)); if (N1.getOpcode() == ISD::FNEG) // ((-A)+B) -> B-A return getNode(ISD::SUB, VT, N2, N1.getOperand(0)); + if (N1.getOpcode() == ISD::SUB && isa<ConstantSDNode>(N1.getOperand(0)) && + cast<ConstantSDNode>(N1.getOperand(0))->getValue() == 0) + return getNode(ISD::SUB, VT, N2, N1.getOperand(1)); // (0-A)+B -> B-A + if (N2.getOpcode() == ISD::SUB && isa<ConstantSDNode>(N2.getOperand(0)) && + cast<ConstantSDNode>(N2.getOperand(0))->getValue() == 0) + return getNode(ISD::SUB, VT, N1, N2.getOperand(1)); // A+(0-B) -> A-B break; case ISD::SUB: if (N1.getOpcode() == ISD::ADD) { |