[llvm] Fix exact backedge count algorithm in Scalar-Evolution (PR #92560)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 09:55:14 PDT 2024
================
@@ -12941,12 +12941,16 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
return RHS;
}
- // When the RHS is not invariant, we do not know the end bound of the loop and
- // cannot calculate the ExactBECount needed by ExitLimit. However, we can
- // calculate the MaxBECount, given the start, stride and max value for the end
- // bound of the loop (RHS), and the fact that IV does not overflow (which is
- // checked above).
if (!isLoopInvariant(RHS, L)) {
+ // If RHS is an add recurrence, try again with lhs=lhs-rhs and rhs=0
----------------
efriedma-quic wrote:
You can't subtract a value from the LHS and RHS of the comparison unless you can prove the subtraction doesn't wrap.
https://github.com/llvm/llvm-project/pull/92560
More information about the llvm-commits
mailing list