[all-commits] [llvm/llvm-project] d0dd37: [MLIR][Canonicalization] Add shape_cast folding pa...

Alexandra Sidorova via All-commits all-commits at lists.llvm.org
Tue Mar 3 10:12:47 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d0dd371249795ef17fac95dd77444baef1fdf578
      https://github.com/llvm/llvm-project/commit/d0dd371249795ef17fac95dd77444baef1fdf578
  Author: Alexandra Sidorova <asidorov at amd.com>
  Date:   2026-03-03 (Tue, 03 Mar 2026)

  Changed paths:
    M mlir/lib/Dialect/Vector/IR/VectorOps.cpp
    M mlir/test/Dialect/Vector/canonicalize.mlir
    A mlir/test/Dialect/Vector/canonicalize/vector-to-elements.mlir

  Log Message:
  -----------
  [MLIR][Canonicalization] Add shape_cast folding patterns (#183061)

### Summary

This PR adds two shape_cast-related canonicalization patterns for
`vector.to_elements` and `vector.from_elements`.

### Details

- Added` ToElements(ShapeCast(X)) -> ToElements(X)` as an in-place fold
in `ToElementsOp::fold`.
- Added `ShapeCast(FromElements(X)) -> FromElements(X)` as an
`OpRewritePattern` — it must be a pattern (not a `fold`) because we have
to create new op `FromElementsOp` with updated result type. This cannot
be done with a `fold`, because `fold` cannot create new ops and the
existing `FromElementsOp` result type differs from the `ShapeCastOp`
result type. Mutating the `FromElementsOp` (not root op) would violate
the `fold` contract and break other users.
- Added lit tests for the both ops (new `vector-to-elements.mlir`,
`vector-from-elements.mlir`)

---------

Signed-off-by: Alexandra Sidorova <asidorov at amd.com>



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