[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
Sat Sep 12 08:20:14 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) ||
----------------
fhahn wrote:

Currently only SLT/SLE can reach here. I added an assert + tests with SGT/SGE, thanks

https://github.com/llvm/llvm-project/pull/222762


More information about the llvm-commits mailing list