[llvm-branch-commits] [llvm] [SCEV] Prove monotonic predicates from loop entry in isKnownViaInduction (PR #231697)
Max Kazantsev via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Oct 20 08:50:26 PDT 2026
================
@@ -11465,9 +11465,18 @@ bool ScalarEvolution::isKnownOnEveryIteration(CmpPredicate Pred,
// It seems backedge guard check is faster than entry one so in some cases
// it can speed up whole estimation by short circuit
- return isLoopBackedgeGuardedByCond(L, Pred, SplitLHS.second,
- SplitRHS.second) &&
- isLoopEntryGuardedByCond(L, Pred, SplitLHS.first, SplitRHS.first);
+ if (isLoopBackedgeGuardedByCond(L, Pred, SplitLHS.second, SplitRHS.second))
+ return isLoopEntryGuardedByCond(L, Pred, SplitLHS.first, SplitRHS.first);
+
+ // If one side is a recurrence of L and the other side is invariant in L,
+ // and the predicate can only change from false to true as the loop
+ // iterates, it holds on every iteration once it holds on entry.
+ auto MP = getMonotonicPredicate(Pred.dropSameSign(), LHS, RHS, L);
----------------
xortator wrote:
Can `getMonotonicPredicate` return non-same-sign predicate for something what initially was samesign? Is it a potential source of regressions?
https://github.com/llvm/llvm-project/pull/231697
More information about the llvm-branch-commits
mailing list