[llvm] [DA] Check monotonicity for subscripts (PR #154527)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 28 08:16:06 PDT 2025


Meinersbur wrote:

> * monotonic checker is redundant with (could be built on top of) SCEV's existing range analysis.

SCEV's range analysis only returns `ConstantRange`. If you expect to have not just INT_MAX/INT_MIN returned, and contains an SCEVAddRecExpr, the min/max could be any of the values described by the SCEVAddRecExpr. It is impossible to enumerate all values if the trip count is not a constant. On the other side, if SCEVAddRecExpr does not wrap and the expression is on that SCEVAddRecExpr is monotonic, you can assume that the entire range falls between the evalution of the SCEVAddRecExpr's start value, and the loop's last iteration.

https://github.com/llvm/llvm-project/pull/154527


More information about the llvm-commits mailing list