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

Alan Li llvmlistbot at llvm.org
Mon May 5 16:50:35 PDT 2025


lialan wrote:

> I wouldn't call it a "failure", I'd just say that the size of the memref has to become less specific to account for the subview?
> 
> I'm not sure I see the problem with going from a `memref<4x4xT, strides<[8, 1], offset: ?>>` to a `memref<32xT, strides<[1], offset: ?>`?
> 
> (Assuming you want to linearize subviews at all)

I went back and looked at existing patterns. And I found two interesting ones:
* `FoldMemRefAliasOpPatterns` would fold subviews into their uses.
* `ExpandStridedMetadataPatterns` would eliminate `SubviewOp` using strided metadata and an reinterpret op.

So both could serve as a prerequisite before the linearizing pass to eliminate the need for handling subview. I don't think we should re-invent it, but instead we should set a pre-requisite pass to handle subviews. I think it should be okay because if we were to handle subview ourselves, we would use reinterpret cast op anyway. 

opinion? @krzysz00 

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


More information about the Mlir-commits mailing list