diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -9758,8 +9758,23 @@ if (isImpliedCondOperands(Pred, LHS, RHS, V, getConstant(Min))) return true; + break; + + // `LHS < RHS` and `LHS <= RHS` are handled in the same way as `RHS > LHS` and `RHS >= LHS` respectively. + case ICmpInst::ICMP_SLE: + case ICmpInst::ICMP_ULE: + if (isImpliedCondOperands(CmpInst::getSwappedPredicate(Pred), RHS, + LHS, V, getConstant(SharperMin))) + return true; LLVM_FALLTHROUGH; + case ICmpInst::ICMP_SLT: + case ICmpInst::ICMP_ULT: + if (isImpliedCondOperands(CmpInst::getSwappedPredicate(Pred), RHS, + LHS, V, getConstant(Min))) + return true; + break; + default: // No change break;