diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-12-20 20:00:31 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-12-20 20:00:31 +0000 |
commit | b0de244f23c2e11505cab729f198dfaaa2028532 (patch) | |
tree | 42ecd11e83e25527f1831b88b60c5c6b79403a32 | |
parent | 87790abb08eea60a2fa090b6d7b498cc625fa3f2 (diff) | |
download | external_llvm-b0de244f23c2e11505cab729f198dfaaa2028532.zip external_llvm-b0de244f23c2e11505cab729f198dfaaa2028532.tar.gz external_llvm-b0de244f23c2e11505cab729f198dfaaa2028532.tar.bz2 |
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
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 074f661..64613b1 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: |