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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Apr 8 23:04:57 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.

Actually on second thought the transformation you suggest is wrong. If something replaces the alloc size with next multiple of 16 it will have to take a subview and then use the result of the subview to replace all the uses of the alloc. Not taking a subview would make your transformation wrong. So there is no issue with the folder. I dont think there is anything wrong with the transformation I suggested above (maybe there is, just saying I dont think there is)

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


More information about the Mlir-commits mailing list