[PATCH] D104066: [SCEV] Use knowledge of stride to prove loops finite for LT exit count computation

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 15 15:35:58 PDT 2021


efriedma added a comment.

If the stride is zero, and RHS is invariant, the comparison feeding the backedge is invariant.  If we don't exit via any other exit, that implies the backedge-taken count is either zero or infinity.

So if we know the loop is finite, the RHS is invariant, we don't exit via any other exit, and the IV doesn't overflow, we can divide strides into three cases:

1. Stride is zero.  The backedge-taken count is zero, as noted above.
2. Stride is negative.  I think we can also prove the backedge-taken count is zero here?
3. Stride is positive.  We can use the standard formula.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104066/new/

https://reviews.llvm.org/D104066



More information about the llvm-commits mailing list