[all-commits] [llvm/llvm-project] 200e8c: [MLIR][MemRef] Fix DimOfReifyRankedShapedTypeOpInt...

Mehdi Amini via All-commits all-commits at lists.llvm.org
Mon Apr 13 03:20:52 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 200e8c589e41f561b8dd7ed7c9b5e5ba26ab8300
      https://github.com/llvm/llvm-project/commit/200e8c589e41f561b8dd7ed7c9b5e5ba26ab8300
  Author: Mehdi Amini <joker.eph at gmail.com>
  Date:   2026-04-13 (Mon, 13 Apr 2026)

  Changed paths:
    M mlir/lib/Dialect/MemRef/Transforms/ResolveShapedTypeResultDims.cpp
    M mlir/test/Interfaces/InferShapedTypeOpInterface/resolve-shaped-type-result-dims.mlir

  Log Message:
  -----------
  [MLIR][MemRef] Fix DimOfReifyRankedShapedTypeOpInterface IR-change on failure (#188973)

DimOfReifyRankedShapedTypeOpInterface::matchAndRewrite called
reifyDimOfResult via the PatternRewriter. Some implementations delegate
to the coarse-grained reifyResultShapes, which creates ops for ALL
dimensions (e.g. a tensor.dim) before discovering that a specific
dimension is not reifiable (signalled by an empty OpFoldResult).

The pattern then returned failure() once it saw the empty OpFoldResult,
but the newly created ops were already in the IR. Under
MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS this triggered "pattern
returned failure but IR did change".

Fix: record the op immediately before the matched dim op, so we can
identify ops inserted during the reification attempt. If reification
returns an empty (unreifiable) OpFoldResult, erase those newly created
ops before returning failure, restoring the IR to its original state.

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