mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
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
This commit is contained in:
parent
87790abb08
commit
b0de244f23
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user