[all-commits] [llvm/llvm-project] 5c3d0d: [mlir][memref] Fix crash in DimOp::fold for subvie...

Mehdi Amini via All-commits all-commits at lists.llvm.org
Thu Mar 5 08:05:21 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5c3d0dd7a482b38e5a68f462d7ea874f55bc67f6
      https://github.com/llvm/llvm-project/commit/5c3d0dd7a482b38e5a68f462d7ea874f55bc67f6
  Author: Mehdi Amini <joker.eph at gmail.com>
  Date:   2026-03-05 (Thu, 05 Mar 2026)

  Changed paths:
    M mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
    M mlir/test/Dialect/MemRef/canonicalize.mlir

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

When a rank-reducing subview has multiple size-1 source dimensions and
all strides are dynamic, `computeMemRefRankReductionMask` cannot
unambiguously determine which dimension is dropped. It would fall back
to an arbitrary choice that could be wrong.

In `DimOp::fold`, the code then maps a result dimension to that
(possibly incorrect) source dimension and asserts
`isDynamicSize(sourceIndex)`. If `getDroppedDims()` picked the wrong
dropped dim, the source dim at `sourceIndex` may be statically sized,
causing the assertion to fire.

Fix this by replacing the assert with a guard that returns `{}` (no
fold) when the resolved source dimension is not dynamic. This is safe
because the fold already handles the statically-sized result case
earlier.

Fixes #111244

Assisted-by: Claude Code



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list