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

Mehdi Amini llvmlistbot at llvm.org
Wed Mar 4 03:19:23 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))
----------------
joker-eph wrote:

Right, this is a better home. Done. Thanks!

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


More information about the Mlir-commits mailing list