[llvm] [DA] Check monotonicity for subscripts (PR #154527)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 22 03:28:10 PDT 2025
https://github.com/Meinersbur commented:
Some thoughts:
* This seems to only support AddRecExpr directly, I was thinking about something recursive that may contain an AddRecExpr, such as an SignExtend/ZeroExtend/Division/... of an SCEVAddRecExpr. The most common operations (mul/add with invariant) may indeed usually be folded into the SCEVAddRecExpr (always?). SCEVTruncate maybe illustrates that the "monotonic" property not only applies to SCEVAddRecExpr.
```
trunc 0x101 to i8 -> 0x01
trunc 0x203 to i8 -> 0x03
trunc 0x302 to i8 -> 0x02
```
Say the values 0x101, 0x203, 0x302 are the AddRecExpr of a loop. The maximum of the trunc expression is `0x03`, which is neither the value of the initial AddRecExpr loop iteration, nor its last.
* I would have thougth of getting the min/max of an expression as a separate operation. Ideally, the simplication of SMin/SMax expression could be done by ScalarEvolution itself through canonicalization/folding.
https://github.com/llvm/llvm-project/pull/154527
More information about the llvm-commits
mailing list