[Mlir-commits] [mlir] [mlir][memref] Support reducing copied dims to non-unit in reinterpret_cast elision (PR #209536)

Andrzej WarzyƄski llvmlistbot at llvm.org
Wed Jul 15 02:33:41 PDT 2026


================
@@ -268,18 +268,20 @@ getResultNonUnitDimsAndOffsetsForRC(memref::ReinterpretCastOp rc) {
 ///   %v = memref.load %src[0, ..., 0]
 ///   memref.store %v, %dst[delinearized(OFF)]
 ///
-///   // BEFORE (one collapsed non-unit dimension)
+///   // BEFORE (same-dimension static slice)
 ///   %strided = memref.reinterpret_cast %dst
-///     to offset: [OFF], sizes: [1, M, 1], strides: [M*N, N, 1]
+///     to offset: [OFF], sizes: [1, M, K], strides: [M*N, N, 1]
 ///     : memref<1xMxNxf32>
-///       to memref<1xMx1xf32, strided<[M*N, N, 1], offset: OFF>>
+///       to memref<1xMxKxf32, strided<[M*N, N, 1], offset: OFF>>
 ///   memref.copy %src, %strided
 ///
 ///   // AFTER
-///   // Assuming OFF delinearizes to [0, 0, OFF]:
----------------
banach-space wrote:

> Therefore, reducing a non-trailing dimension can delinearize OFF to a different index.

Sure, but that's the case for more general examples. For the example from the comment, `OFF -> [0, 0, OFF]` would be correct - it's worth noting that. Also, `OFF -> j` feels off (i.e. switching from ALL_CAPS to lower_case). I suggest `OFF` --> `DELIN_OFF`.

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


More information about the Mlir-commits mailing list