[Mlir-commits] [mlir] [mlir] remove folder on MemRef::ExtractStridedMetadataOp (PR #88043)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Apr 8 22:57:02 PDT 2024


MaheshRavishankar wrote:

> I can see the problem, but I don't that would make the folding incorrect. Imo, the correct way to fix this is to insert the `memref.extract_strided_metadata` at the point of time when you actually need the offset. I see `memref.extract_strided_metadata` as a kind of analysis result that is materialized in IR, and changing the IR invalidates the analysis.
> 
> I think you can run into similar issues with all kind of folding/canonicalizations; e.g.:
> 
> ```mlir
> %m = memref.alloc(%sz) : memref<?xf32>
> %0 = memref.dim %m, %c0
> func.call @foo(%m, %0)
> ```
> 
> Now you could have a hypothetical pass that changes the allocation size to the next multiple of 16, but `%0` was already folded to `%sz` and is no longer correct.

There is no way you can control when the folding runs. So expecting that this operation be inserted "only after all buffer manipulations happen" is kind of strange. If you still want the optimizations to kick in, then maybe these folding could be moved into patterns that can be run when needed instead of it happening without control. 

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


More information about the Mlir-commits mailing list