================
@@ -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
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to