summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-12-20 20:00:31 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-12-20 20:00:31 +0000
commitb0de244f23c2e11505cab729f198dfaaa2028532 (patch)
tree42ecd11e83e25527f1831b88b60c5c6b79403a32 /lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
parent87790abb08eea60a2fa090b6d7b498cc625fa3f2 (diff)
downloadllvm-b0de244f23c2e11505cab729f198dfaaa2028532.tar.gz
llvm-b0de244f23c2e11505cab729f198dfaaa2028532.tar.bz2
llvm-b0de244f23c2e11505cab729f198dfaaa2028532.tar.xz
Add a check missing from my last commit and avoid a potential overflow situation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122258 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineAndOrXor.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineAndOrXor.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 074f6610c4..64613b186e 100644
--- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1449,13 +1449,13 @@ Value *InstCombiner::FoldOrOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
}
}
- // (icmp ult (X + CA), C1) | (icmp eq X, C2) -> (icmp ult (X + CA), C1 + 1)
+ // (icmp ult (X + CA), C1) | (icmp eq X, C2) -> (icmp ule (X + CA), C1)
// iff C2 + CA == C1.
- if (LHSCC == ICmpInst::ICMP_ULT) {
+ if (LHSCC == ICmpInst::ICMP_ULT && RHSCC == ICmpInst::ICMP_EQ) {
ConstantInt *AddCst;
if (match(Val, m_Add(m_Specific(Val2), m_ConstantInt(AddCst))))
if (RHSCst->getValue() + AddCst->getValue() == LHSCst->getValue())
- return Builder->CreateICmp(LHSCC, Val, AddOne(LHSCst));
+ return Builder->CreateICmpULE(Val, LHSCst);
}
// From here on, we only handle: