[Mlir-commits] [mlir] [mlir] Compose expand of collapse to cast (PR #172864)

Maya Amrami llvmlistbot at llvm.org
Sat Dec 20 23:07:29 PST 2025


================
@@ -1193,6 +1193,25 @@ func.func @collapse_expand_fold_to_cast(%m: memref<?xf32, strided<[1]>, 3>, %sz0
 
 // -----
 
+// CHECK-LABEL: func @expand_collapse_fold_to_cast(
+//  CHECK-SAME:     %[[m:.*]]: memref<1x1x384x384xui8, strided<[1179648, 147456, 384, 1]>>
+//       CHECK:   %[[casted:.*]] = memref.cast %[[m]] : memref<1x1x384x384xui8, strided<[1179648, 147456, 384, 1]>> to memref<1x1x384x384xui8, strided<[1179648, 1179648, 384, 1]>>
----------------
amrami wrote:

In my case the collapse expand were in tensors and after bufferization I get this situation.
Note that if y=expand(collapse(x)), here type(y) != type(x). This is why this cast is not really a no op.

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


More information about the Mlir-commits mailing list