diff options
author | Chris Lattner <sabre@nondot.org> | 2005-08-10 17:37:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-08-10 17:37:53 +0000 |
commit | 21c0fd9e8f0743ac2a8036c50c43331bf053ab5b (patch) | |
tree | ae6c7ef56c1d582a74535cdb0fd5f7c6cf31d4b8 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 1a92cb2cd1eccce69e8f2c7bc6977c634b609ef5 (diff) | |
download | bcm5719-llvm-21c0fd9e8f0743ac2a8036c50c43331bf053ab5b.tar.gz bcm5719-llvm-21c0fd9e8f0743ac2a8036c50c43331bf053ab5b.zip |
Fix an oversight that may be causing PR617.
llvm-svn: 22753
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index c2d5de841ef..549b48042f9 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -626,12 +626,21 @@ SDOperand SelectionDAG::SimplifySetCC(MVT::ValueType VT, SDOperand N1, if (N2.getOpcode() == ISD::ADD || N2.getOpcode() == ISD::SUB || N2.getOpcode() == ISD::XOR) { // Simplify X == (X+Z) --> Z == 0 - if (N2.getOperand(0) == N1) + if (N2.getOperand(0) == N1) { return getSetCC(VT, N2.getOperand(1), getConstant(0, N2.getValueType()), Cond); - else if (N2.getOperand(1) == N1) - return getSetCC(VT, N2.getOperand(0), getConstant(0, N2.getValueType()), - Cond); + } else if (N2.getOperand(1) == N1) { + if (isCommutativeBinOp(N2.getOpcode())) { + return getSetCC(VT, N2.getOperand(0), + getConstant(0, N2.getValueType()), Cond); + } else { + assert(N2.getOpcode() == ISD::SUB && "Unexpected operation!"); + // X == (Z-X) --> X<<1 == Z + return getSetCC(VT, getNode(ISD::SHL, N2.getValueType(), N1, + getConstant(1, TLI.getShiftAmountTy())), + N2.getOperand(0), Cond); + } + } } } |