[Mlir-commits] [mlir] [mlir][memref] Fix crash in DimOp::fold for subview with ambiguous dropped dims (PR #183995)

Longsheng Mou llvmlistbot at llvm.org
Mon Mar 2 00:58:39 PST 2026


================
@@ -1084,8 +1084,12 @@ OpFoldResult DimOp::fold(FoldAdaptor adaptor) {
       }
       resultIndex++;
     }
-    assert(subview.isDynamicSize(sourceIndex) &&
-           "expected dynamic subview size");
+    // If the source dimension is not dynamic, getDroppedDims() may have
+    // computed an incorrect mapping (e.g., when strides are all dynamic and
+    // there are multiple unit-size candidate dimensions), so conservatively
+    // bail out.
+    if (!subview.isDynamicSize(sourceIndex))
----------------
CoTinker wrote:

I think we should add a test in mlir/test/Dialect/MemRef/canonicalize.mlir

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


More information about the Mlir-commits mailing list