[Mlir-commits] [mlir] [mlir][memref] Fix crash in DimOp::fold for subview with ambiguous dropped dims (PR #183995)
Mehdi Amini
llvmlistbot at llvm.org
Thu Mar 5 05:53:28 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))
+ return {};
return subview.getDynamicSize(sourceIndex);
----------------
joker-eph wrote:
That works, but Claude found a simplification that avoids even calling `getDroppedDims()` in the first place!
https://github.com/llvm/llvm-project/pull/183995
More information about the Mlir-commits
mailing list