aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-08-10 17:37:53 +0000
committerChris Lattner <sabre@nondot.org>2005-08-10 17:37:53 +0000
commit7c6e452d4415abaeb562958bbae1ca1bc2eb6809 (patch)
treefd8254c1649f9cc80f80ce1136e6e7a6123fc783 /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent6d92526fe19a0896e63b41cb4639a4aa75fdaa16 (diff)
Fix an oversight that may be causing PR617.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22753 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index c2d5de841e..549b48042f 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/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);
+ }
+ }
}
}