[Mlir-commits] [mlir] [mlir][affine] Use value bound inference to determine minimum/maximum trip counts in loop analysis (PR #128113)

lonely eagle llvmlistbot at llvm.org
Mon Apr 14 02:37:12 PDT 2025


linuxlonelyeagle wrote:

> Affine loop transformations shouldn't care about block sizes or thread IDs. They should only reason about ranges of the induction variables, regardless of where those ranges come from.
yes, you are right.I'm only using an example because I can only think of the gpu situation because I touch the thing every day. But the work done by this PR wouldn't be limited to GPUs only, if a Value has RANGE, this PR works too.

> It appears to me that the loop must be preserved whenever the upper bound is not equal to the lower bound, which is equivalent to saying we cannot find the single constant bound (min=max=constant). This is exactly what we already do, just using less powerful reasoning.
you are right.

> The upper bound of the affine loop is systematically a minimum of all the expressions. So if you two expressions with ranges [4, 6] and [2, 3] (non-overlapping), the expressions with [4, 6] will never affect the bound. We can even remove it as an optimization.
Here you should think wrong. Although they don't overlap, the lower bounds are 2 and 4 respectively, which means that the maximum unroll factor a loop can have is 2, and the other is 4, and they can unroll together twice.

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


More information about the Mlir-commits mailing list