forked from OSchip/llvm-project
Add a check missing from my last commit and avoid a potential overflow situation.
llvm-svn: 122258
This commit is contained in:
parent
8e37ea1a29
commit
f7957d0463
|
@ -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