[llvm] [ConstraintElim] Derive an unsigned IV bound from a signed relational latch. (PR #222762)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 11:55:41 PDT 2026
================
@@ -1159,6 +1159,18 @@ 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)) {
+ MonotonicInfo Info = getMonotonicityInfo(*PN, Backedge);
+ if ((Info.Signed && !Info.Decreasing) ||
----------------
dtcxzyw wrote:
IIRC it should be `) &&` here. For decreasing sequences, `nneg Backage s> B` should not imply that B is also non-negative. Then you cannot convert the predicate into an unsigned one.
https://github.com/llvm/llvm-project/pull/222762
More information about the llvm-commits
mailing list