[Mlir-commits] [mlir] [MLIR] Add a utility pass to linearize `memref` (PR #136797)

Krzysztof Drewniak llvmlistbot at llvm.org
Mon May 5 08:39:28 PDT 2025


krzysz00 wrote:

> I think this is more related to how we interpret "linearize indices", In my opinion this pass should only linearize memref.load's indices but not change its memref size. We should call something likeFoldMemRefAliasOps instead for folding memrefs.

I don't think you can do that correctly if you're trying to linearize the index computation for a subview - or, even outside fo a subview, any strided memref

Remember, every index in a `memref.load %m[%i0, %i1, ... %in] : memref<L0 x L1 ... x Ln x T, layout>` has to have `0 <= %i_k < L_k`. So if I have a `%m : memref<4x4xf32, strided<[8, 1]>>`, then if I determine the ultimate index of `%m[%i, %j]` to be `%j + 8 * %i` - which it  is -, I need to allow for `0 <= %j  + 8 * %i < 32`, because otherwise we'll break the memref.load invariants.



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


More information about the Mlir-commits mailing list