[llvm] [ConstraintElim] Derive an unsigned IV bound from a signed relational latch. (PR #222762)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 13 11:09:32 PDT 2026
================
@@ -1188,6 +1188,20 @@ void State::addInfoForInductions(BasicBlock &BB) {
WorkList.push_back(FactOrCheck::getConditionFact(
DTN, ContinuePred, PN, B, ConditionTy(ContinuePred, StartValue, B)));
+ // For a non-negative backedge value, 0 s<= PN s< B implies B is
+ // non-negative as well, so the same bound holds in the unsigned system.
+ if (ICmpInst::isSigned(ContinuePred)) {
+ assert((ContinuePred == CmpInst::ICMP_SLT ||
+ ContinuePred == CmpInst::ICMP_SLE) &&
+ "Expected a signed less-than continuation predicate");
+ MonotonicInfo Info = getMonotonicityInfo(*PN, Backedge);
+ if ((Info.Signed && !Info.Decreasing)) {
+ CmpInst::Predicate UPred = ICmpInst::getUnsignedPredicate(ContinuePred);
+ WorkList.push_back(FactOrCheck::getConditionFact(
----------------
fhahn wrote:
Yep, I tried to update the comment, thanks.
https://github.com/llvm/llvm-project/pull/222762
More information about the llvm-commits
mailing list