[llvm] Fix exact backedge count algorithm in Scalar-Evolution (PR #92560)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 18 00:26:27 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
----------------
mrdaybird wrote:
@efriedma-quic Oh!
So suppose, we can prove that LHS Start < RHS Start and we know stride of lhs is positive and stride of RHS is negative then it should do the trick right?
https://github.com/llvm/llvm-project/pull/92560
More information about the llvm-commits
mailing list