601 Commits

Author SHA1 Message Date
Han-Chung Wang
9e44babdaf
[mlir][vector] Add support for dropping inner unit dims for transfer_read/write with masks. (#188841)
The revision clears a long-due TODO, which supports the lowering when
transfer_read/write ops have mask via inserting a vector.shape_cast op
for the masked value.

---------

Signed-off-by: hanhanW <hanhan0912@gmail.com>
2026-03-27 10:21:20 -07:00
Mehdi Amini
c0e8eb972b
[MLIR][Vector] Fix RewriteAlignedSubByteIntExt/Trunc producing invalid IR when source is already i8 (#188941)
When the conversion destination type is i8 (e.g., extsi i4->i8),
RewriteAlignedSubByteIntExt was unconditionally creating a new
ConversionOp with identical source and result types (vector<8xi8> ->
vector<8xi8>), which is invalid IR. Similarly,
RewriteAlignedSubByteIntTrunc was creating arith.trunci from
vector<Nxi8> to vector<Nxi8> when the source was already i8.

Fix by:
- In RewriteAlignedSubByteIntExt: replace the op directly with
subByteExt when it already has the destination type, instead of wrapping
in a new conversion op.
- In RewriteAlignedSubByteIntTrunc: skip the intermediate truncation to
i8 when the source is already i8, passing srcValue directly to the
i8->i4 rewrite logic.

This matches the existing test expectations in
vector-rewrite-subbyte-ext-and-trunci.mlir.

Assisted-by: Claude Code
Fix a failure present with MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON.
2026-03-27 12:34:47 +01:00
Mehdi Amini
329432b351
[MLIR][Vector] Move scalable dims check before IR creation in ScanToArithOps (#188954)
ScanToArithOps::matchAndRewrite created the result arith.constant before
checking whether the reduction dimension is scalable. When the dimension
was scalable, the pattern returned notifyMatchFailure() after IR was
already modified, violating MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS.

Fix: move the reductionScalableDims check to before the
arith::ConstantOp creation.

Assisted-by: Claude Code
Fix a failure present with MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON.
2026-03-27 12:25:14 +01:00
Mehdi Amini
17e1438c6b
[MLIR][Vector] Move scalable dims check before IR creation in BroadcastOpLowering (#188953)
BroadcastOpLowering::matchAndRewrite created ub::PoisonOp before
checking whether a scalable outer dimension prevents the
stretch-not-at-start case. When that check triggered, the pattern
returned failure() after IR was already modified, violating
MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS.

Fix: move the scalable dimension check to before the PoisonOp creation.

Assisted-by: Claude Code
Fix a failure present with MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON.
2026-03-27 12:24:57 +01:00
Jakub Kuderski
107d8539d0
[mlir] Add Repeated<T> constructors for TypeRange and ValueRange (#186923)
Many MLIR APIs end up using a range of the same Type / Value repeated N
times, due to the (function of the) dimensionality of the problem.
Allocating a vector of N identical element is wasteful.

Add `Repeated<T>` as PointerUnion variants in TypeRange and ValueRange,
enabling O(1) storage for repeated elements. Size remains 2 pointers (16
bytes on 64-bit) for both range types. This required variable-width
`PointerUnion` encoding added in
https://github.com/llvm/llvm-project/pull/188167 on 32-bit systems.

Also update several MLIR dialects and conversions to exercise the new
code.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 07:20:12 -04:00
Han-Chung Wang
305dc4e5a9
[mlir][vector] Lower vector.gather with delinearization approach (#184706)
The old implementation did not handle n-D memref correctly, which leads
to wrong access. E.g.,

```
 func.func @gather_memref_2d(%base: memref<?x?xf32>, %v: vector<2x3xindex>, %mask: vector<2x3xi1>, %pass_thru: vector<2x3xf32>) -> vector<2x3xf32> {
  %c0 = arith.constant 0 : index
  %c1 = arith.constant 1 : index
  %0 = vector.gather %base[%c0, %c1][%v], %mask, %pass_thru : memref<?x?xf32>, vector<2x3xindex>, vector<2x3xi1>, vector<2x3xf32> into vector<2x3xf32>
  return %0 : vector<2x3xf32>
 }
```

is lowered to

```
  func.func @gather_memref_2d(%arg0: memref<?x?xf32>, %arg1: vector<2x3xindex>, %arg2: vector<2x3xi1>, %arg3: vector<2x3xf32>) -> vector<2x3xf32> {
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1 : index
    %0 = ub.poison : vector<2x3xf32>
    %1 = vector.extract %arg3[0] : vector<3xf32> from vector<2x3xf32>
    %2 = vector.extract %arg2[0, 0] : i1 from vector<2x3xi1>
    %3 = vector.extract %arg1[0, 0] : index from vector<2x3xindex>
    %4 = arith.addi %3, %c1 : index
    %5 = scf.if %2 -> (vector<3xf32>) {
      %29 = vector.load %arg0[%c0, %4] : memref<?x?xf32>, vector<1xf32>
      %30 = vector.extract %29[0] : f32 from vector<1xf32>
      %31 = vector.insert %30, %1 [0] : f32 into vector<3xf32>
      scf.yield %31 : vector<3xf32>
    } else {
      scf.yield %1 : vector<3xf32>
    }
    // ...
```

The revision fixes it by by using `linearize(baseOffsets) + gatherIndex`
followed by `delinearize` to recover correct `n-D` load indices. This is
applied unconditionally for all rank > 1 memrefs.

Note that it enables the cases with strideds because we use
delinearization approach.

---------

Signed-off-by: hanhanW <hanhan0912@gmail.com>
2026-03-13 14:58:40 -07:00
Adam Siemieniuk
c21a5ac736
[mlir][vector] Flatten transfer - support multi-dim scalar element (#185417)
Adds support for flattening multi-dimensional scalar vector transfers.

The addition prevents pattern crashes on such inputs and allows for
cleaner lowering of scalar vectors.
2026-03-09 17:45:15 +01:00
Erick Ochoa Lopez
613a5c555e
[mlir][vector] Replace OneDimMultiReductionToTwoDim with OneDimMultiReductionToReduction (#184241)
The `OneDimMultiReductionToTwoDim` pattern had some issues. For the
input program:

```mlir
func.func @rank1_multi_reduction(%arg0: vector<8xf32>, %acc: f32) -> f32 {
    %0 = vector.multi_reduction <add>, %arg0, %acc [0] : vector<8xf32> to f32
    return %0 : f32
}
```

* when lowering using the inner-parallel strategy, the compiler would
essentially produce scalar code:
```mlir
func.func @rank1_multi_reduction(%arg0: vector<8xf32>, %arg1: f32) -> f32 {
    %0 = vector.shape_cast %arg0 : vector<8xf32> to vector<1x8xf32>
    %1 = vector.broadcast %arg1 : f32 to vector<1xf32>
    %2 = vector.transpose %0, [1, 0] : vector<1x8xf32> to vector<8x1xf32>
    %3 = vector.extract %2[0] : vector<1xf32> from vector<8x1xf32>
    %4 = arith.addf %3, %1 : vector<1xf32>
    %5 = vector.extract %2[1] : vector<1xf32> from vector<8x1xf32>
    %6 = arith.addf %5, %4 : vector<1xf32>
    ... (repeats for all 8 elements) ...
    %17 = vector.extract %2[7] : vector<1xf32> from vector<8x1xf32>
    %18 = arith.addf %17, %16 : vector<1xf32>
    %19 = vector.extract %18[0] : f32 from vector<1xf32>
    return %19 : f32
}
```
* when lowering using the inner-reduction strategy, the compiler would
first unnecessarily transform it into a 2-D multi_reduction operation
<1x8xf32> and then extract an <8xf32> vector and apply reduction. The
canonicalization and folding would lead to the following final result:
```mlir
func.func @rank1_multi_reduction(%arg0: vector<8xf32>, %arg1: f32) -> f32 {
    %0 = vector.reduction <add>, %arg0, %arg1 : vector<8xf32> into f32
    return %0 : f32
}
```

Now, after this change:
* when lowering the compiler now produces for both strategies in one
step.
```
func.func @rank1_multi_reduction(%arg0: vector<8xf32>, %arg1: f32) -> f32 {
    %0 = vector.reduction <add>, %arg0, %arg1 : vector<8xf32> into f32
    return %0 : f32
}
```

This pattern is also useful for an ongoing refactoring that is happening
in the multi_reduction patterns. It is the only pattern that increases
multi_reduction in rank and would lead to an infinite loop when
attempting to reach a fixed point once we generalize other unrolling
patterns.

Assisted-by: Claude
2026-03-04 16:13:11 +00:00
Artem Gindinson
97043e50ad
[mlir][Vector][GPU] Distribute expanding shape_cast ops (#183830)
The initial implementation of `shape_cast` distribution only focused on
scenarios with collapsing shape casts. Within downstream pipelines such
as IREE, commit 962a9a3 exposes an issue with this implementation, where
the rank-expanding cast ops (stemming from the new `vector.broadcast`
canonicalization) silently fall through to the "collapsing-or-no-op"
logic. This brings about bugs with rank mismatches and firing validation
assertions when distributing rather common reshaping sequences
encountered after CSE/ canonicalization, such as below:
```
  // Example 1: gather op
  %weight = arith.constant dense_resource<__elided__> : tensor<256xi8>
  %c0 = arith.constant 0 : index
  ...
  %expand = vector.shape_cast <...> : vector<1xindex> to vector<1x1xindex>
  %gather = vector.gather %weight[%c0] [%expand], <...>, <...> : memref<256xi8>, vector<1x1xindex>, vector<1x1xi1>, vector<1x1xi8> into vector<1x1xi8>
  %collapse_back = vector.shape_cast %gather : vector<1x1xi8> to vector<1xi8>
  // Example 2: multi-reduction
  %expand = vector.shape_cast <...>: vector<1x96xi32> to vector<1x2x48xi32>
  %reduce = vector.multi_reduction <add>, %expand, <...> [1, 2]: vector<1x2x48xi32> to vector<1x1xi32>
  %collapse = vector.shape_cast %reduce : vector<1x1xi32> to vector<1xi32>
```

This commit adds initial handling of expanding `shape_cast`s, going
through the three scenarios:
- if all "excess" dimensions in the front of the destination shape are
unit, it's clear that the work is not distributed across those, so we
strip the same number of unit dimensions from the per-lane yielded type;
- if the source type within the warp code is of rank 1, we still
determine the corresponding output type cleanly by multiplying the
dimensions of the per-lane yield type;
- if neither of the above are true, explicitly fail the pattern for such
expanding `shape_cast`'s. Dimension-specific distribution parameters are
deemed ambiguous, at least from within this pattern's context.

---------

Signed-off-by: Artem Gindinson <gindinson@roofline.ai>
2026-03-03 14:10:40 +01:00
Jakub Kuderski
386a3afa55
[mlir] Fix typos that propagate downstream. NFC. (#184220) 2026-03-02 20:36:03 +00:00
Andrzej Warzyński
ed05f7012f
[mlir][vector] Rename ReduceMultiDimReductionRank -> FlattenMultiReduction (NFC) (#183721)
The updated name better captures what the pattern does and matches the
coresponding `populat*` hook,
`populateVectorMultiReductionFlatteningPatterns`, that only contains
this pattern.
2026-02-27 16:23:06 +00:00
Jianhui Li
7cc27e28db
[MLIR][Vector] Enhance shape_cast unrolling support in case the target shape is [1, 1, ..1] (#183436)
This PR fixes a minor issue in shape_cast unrolling: when all target
dimensions are unit-sized, it no longer removes all leading unit
dimensions.
2026-02-27 07:11:27 -08:00
Andrzej Warzyński
7aa74c918a
[mlir][vector] Refactor multi-reduction patterns (NFC) (#183048)
Refactor the following patterns to inherit from
`MaskableOpRewritePattern`:
  * `TwoDimMultiReductionToReduction`
  * `TwoDimMultiReductionToElementWise`

This improves code reuse, enables small simplifications, and unifies the
structure of the patterns. Add high-level comments to clarify the
overall lowering strategy.

Prepares for future refactoring (e.g. #182301) and helps maintain a
uniform implementation.
2026-02-26 09:34:33 +00:00
Erick Ochoa Lopez
eeb6b394c5
[mlir][vector] remove lower_multi_reduction (#182332)
* Removes `ApplyLowerMultiReductionPatternsOp`
(`apply_patterns.vector.lower_multi_reduction`)
* Updates uses of `apply_patterns.vector.lower_multi_reduction` in tests
to use:
  *  reorder_and_expand_multi_reduction_dims
  * multi_reduction_flattening
   * multi_reduction_unrolling
* Removes `populateVectorMultiReductionLoweringPatterns` (unused)
2026-02-20 08:33:24 -05:00
Erick Ochoa Lopez
6ec5c1e368
[mlir][vector] Add multi_reduction_flattening (#181244)
* Adds tests for `populateVectorMultiReductionFlatteningPatterns`
* Add apply_patterns.vector.multi_reduction_flattening transform op.

This follows PR #180977. 

Assisted-by: claude
2026-02-18 14:40:24 -05:00
Erick Ochoa Lopez
3cf4156198
[mlir][vector] add ApplyReorderMultiReductionDimsPatternsOp tests (#180977)
With the new finer grained populate methods introduced in
8dde3051504cb9ae42e654bbce39001f3946beea (#180750), there was a
discussion about refactoring tests such that only one of the patterns
applies at a time. This commit starts this process by adding the
structure for one of these populate methods. The goal is for the
populate methods to have their own file (each showing inner and outer
reduction); deprecating populateVectorMultiReductionLoweringPatterns and
ApplyLowerMultiReduction; and removing the test file for
mlir/test/Dialect/Vector/vector-multi-reduction-lowering.mlir

Essentially an NFC. It also adds a new transform op for testing the
dialect and which downstream projects may choose to use.

Assisted-By: claude-4.5-sonnet
2026-02-17 16:14:59 -05:00
Erick Ochoa Lopez
8dde305150
[mlir][vector] Add finer grained populate methods for multi_reduction (NFC). (#180750)
Thiese commits add three more populate methods for
`vector.multi_reduction`'s lowering patterns:

* populateVectorMultiReductionTransformationPatterns
* populateVectorMultiReductionFlatteningPatterns
* populateVectorMultiReductionUnrollingPatterns

These methods have a
finer level of granularity and allow users to select between unrolling,
flattening, and applying transformations that would set up operations
for unrolling and flattening.

The previous populateVectorMultiReductionLoweringPatterns method
is rewritten in terms of these new methods.
2026-02-10 21:27:23 +00:00
Noah Prisament
e2b7cbf71f
Fix outdated docs with vector.reduce instead of vector.reduction (#178111)
There is no existing `vector.reduce` op in the vector dialect, but
multiple doc strings reference it. This change updates those instances
to the correct `vector.reduction` op.
2026-02-02 17:52:04 +00:00
Han-Chung Wang
84c66f4f0d
[mlir][vector] Add assumeAligned mode to vector.store narrow type emulation (#178565)
The revision adds a new `assumeAligned` mode to the emulation, so
downstream projects can use simple path when it meets the requirements.
E.g., if the offset is always aligned with container's element type, we
can skip the check of front padding sizes.

---------

Signed-off-by: hanhanW <hanhan0912@gmail.com>
2026-01-29 18:27:18 +00:00
Jakub Kuderski
9aaf0b89f5
[mlir] Apply clang-tidy check llvm-use-vector-utils. NFC. (#178526) 2026-01-29 02:19:00 +00:00
Jakub Kuderski
59e44799bd
[mlir] Fix new clang-tidy warning llvm-type-switch-case-types. NFC. (#178487)
Pre-commiting this before landing the new check in
https://github.com/llvm/llvm-project/pull/177892
2026-01-28 19:13:47 +00:00
Artem Kroviakov
0926743e2e
[MLIR][XeGPU] Add uniform values distribution pattern (#176737) 2026-01-26 21:23:31 +01:00
Prathamesh Tagore
32d46c9033
[mlir][vector] Fix masked load/store emulation for rank-0 memrefs (#173325)
Added rank‑0 handling to masked load/store emulation by reinterpreting
rank‑0 memrefs as 1‑D buffers with a synthetic index, preventing
empty‑indices crashes.

Fixes https://github.com/llvm/llvm-project/issues/131243
2026-01-05 17:56:09 +00:00
Longsheng Mou
a46cb15b42
[mlir][vector] Fix typo in vector.contract mnemonic (NFC) (#173661) 2025-12-31 09:31:59 +08:00
Prathamesh Tagore
8e90208037
[mlir][vector] Skip vector mask elimination for funcs without body (#173330) 2025-12-29 22:37:16 +00:00
Artem Kroviakov
aba8ebbda0
[MLIR][Vector] Add distribution pattern for vector::ConstantMaskOp (#172268) 2025-12-16 17:24:13 +01:00
Nishant Patel
71ee84acc4
[MLIR][Vector] Add unroll pattern for vector.constant_mask (#171518)
This PR adds unrolling for vector.constant_mask op based on the
targetShape. Each unrolled vector computes its local mask size in each
dimension (d) as:
min(max(originalMaskSize[d] - offset[d], 0), unrolledMaskSize[d]).
2025-12-11 13:16:55 -08:00
Men-cotton
94ebcfd16d
[mlir][vector] Fix crash in ReorderCastOpsOnBroadcast with non-vector result (#170985)
Fixes a crash in `ReorderCastOpsOnBroadcast` by ensuring the cast result
is a `VectorType` before applying the pattern.
A regression test has been added to
mlir/test/Dialect/Vector/vector-sink.mlir.

Fixes: #126371
2025-12-09 16:38:02 +00:00
Nishant Patel
7931e2fd52
[MLIR][Vector] Add unroll pattern for vector.create_mask (#169119)
This PR adds unrolling for vector.create_mask op based on the
targetShape. Each unrolled vector computes its local mask size in each
dimension (d) as:
min(max(originalMaskSize[d] - offset[d], 0), unrolledMaskSize[d]).
2025-12-03 13:38:17 -08:00
Andrzej Warzyński
cfda27d0fb
[mlir][Vector] Add support for scalable vectors to ScanToArithOps (#123117)
Note, scalable reductions dims are left as a TODO.
2025-11-20 13:39:52 +00:00
Nishant Patel
af73aeaa19
[MLIR][Vector] Add unroll pattern for vector.shape_cast (#167738)
This PR adds pattern for unrolling shape_cast given a targetShape. This
PR is a follow up of #164010 which was very general and was using
inserts and extracts on each element (which is also
LowerVectorShapeCast.cpp is doing).
After doing some more research on use cases, we (me and @Jianhui-Li )
realized that the previous version in #164010 is unnecessarily generic
and doesn't fit our performance needs.

Our use case requires that targetShape is contiguous in both source and
result vector.

This pattern only applies when contiguous slices can be extracted from
the source vector and inserted into the result vector such that each
slice remains in vector form with targetShape (and not decompose to
scalars). In these cases, the unrolling proceeds as:

vector.extract_strided_slice -> vector.shape_cast (on the slice
unrolled) -> vector.insert_strided_slice
2025-11-19 16:16:44 -08:00
Ryutaro Okada
7e7ea9c535
[MLIR] Extend vector.scatter to accept tensor as base (#165548)
This PR makes the following improvements to `vector.scatter` and its
lowering pipeline:
- In addition to `memref`, accept a ranked `tensor` as the base operand
of `vector.scatter`, similar to `vector.transfer_write`.
- Implement bufferization support for `vector.scatter`, so that
tensor-based scatter ops can be fully lowered to memref-based forms.

It's worth to complete the functionality of map_scatter decomposition.
Full discussion can be found here:
https://github.com/iree-org/iree/issues/21135

---------

Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
2025-11-14 19:56:24 +00:00
Charitha Saumya
1e8834ea3a
[mlir][vector][xegpu] Accept uniform values in getDistributedType (#163887)
Uniform values should not be distributed during vector distribution.
Example would be a reduction result where reduction happens across
lanes.

However, current `getDistributedType` does not accept a zero result
affine map (i.e. no distributed dims) when describing the distributed
dimensions. This result in null type being returned and crashing the
vector distribution in some cases. An example case would be a `scf.for`
op (about to be distributed) in which one of the for result is a uniform
value and it does not have a user outside the warp op. This necessitates
querying the `getDistributedType` to figure our the distributed type of
this value.
2025-10-22 08:41:41 -07:00
Jakub Kuderski
ae11c5c2c4
[mlir] Switch uses of deprecated .create methods to free function. NFC. (#164635)
See https://discourse.llvm.org/t/psa-opty-create-now-with-100-more-tab-complete/87339.
2025-10-22 14:51:03 +00:00
James Newling
fe5b72a0e8
[mlir][Vector] Pattern to linearize broadcast (#163845)
The PR https://github.com/llvm/llvm-project/pull/162167 removed a
pattern to linearize vector.splat, without adding the equivalent pattern
for vector.broadcast. This PR adds such a pattern, hopefully brining
vector.broadcast up to full parity with vector.splat that has now been
removed.

---------

Signed-off-by: James Newling <james.newling@gmail.com>
2025-10-17 23:31:18 +00:00
Charitha Saumya
f7a5264890
[mlir][vector] Add support for yielding loop bounds in scf.for distribution. (#163443)
In some cases, loop bounds (lower, upper and step) of `scf.for` can come
locally from the parent warp op the `scf.for`. Current logic will not
yield the loop bounds in the new warp op generated during lowering
causing sinked `scf.for` to have non dominating use.

In this PR, we have added logic to yield loop bounds by default (treat
them as other operands of `scf.for`) which fixes this bug.
2025-10-17 09:07:17 -07:00
Nishant Patel
4ff8f118cc
[MLIR][Vector] Extend elementwise pattern to support unrolling from higher rank to lower rank (#162515)
This PR enhances the elementwise unrolling pattern to support higher
rank to lower rank unroll. The approach is to add leading unit dims to
lower rank targetShape to match the rank of original vector (because
ExtractStridedSlice requires same rank to extractSlices), extract slice,
reshape to targetShape's rank and perform the operation.
2025-10-15 06:51:23 -07:00
Artem Kroviakov
0a71fd1528
[MLIR][Vector] Improve warp distribution robustness (#161647) 2025-10-15 10:52:24 +02:00
Jakub Kuderski
0820266651
[mlir] Use llvm accumulate wrappers. NFCI. (#162957)
Use wrappers around `std::accumulate` to make the code more concise and
less bug-prone: https://github.com/llvm/llvm-project/pull/162129.

With `std::accumulate`, it's the initial value that determines the
accumulator type. `llvm::sum_of` and `llvm::product_of` pick the right
accumulator type based on the range element type.

Found some funny bugs like a local accumulate helper that calculated a
sum with initial value of 1 -- we didn't hit the bug because the code
was actually dead...
2025-10-11 11:33:18 -04:00
James Newling
ea291d0e8c
[MLIR][Vector] Remove vector.splat (#162167)
vector.splat has been deprecated (user: please use the very similar vector.broadcast instead) 
with the last PR landing about 6 weeks ago.

The discourse discussion is at
https://discourse.llvm.org/t/rfc-mlir-vector-deprecate-then-remove-vector-splat/87143/1
The last PR was #152230

This PR completely removes vector.splat. In addition to removing vector.splat from VectorOps.td, it

- Updates the few remaining places where vector::SplatOp is created (now vector::BroadcastOp is created)
- Removes temporary patterns where vector.splat is replaced by vector.broadcast

The only place 'vector.splat' appears is now the files

https://github.com/llvm/llvm-project/blob/main/mlir/utils/tree-sitter-mlir/test/corpus/op.txt
 and

https://github.com/llvm/llvm-project/blob/main/mlir/utils/tree-sitter-mlir/dialect/vector.js

---------

Signed-off-by: James Newling <james.newling@gmail.com>
2025-10-10 09:58:18 -07:00
Mehdi Amini
eabfed8690 [MLIR] Apply clang-tidy fixes for modernize-use-bool-literals in VectorEmulateNarrowType.cpp (NFC) 2025-10-03 11:04:58 -07:00
Jakub Kuderski
3960ff6ca0
[mlir][vector] Simplify op rewrite pattern inheriting constructors. NFC. (#161670)
Use the `Base` type alias from
https://github.com/llvm/llvm-project/pull/158433.
2025-10-02 19:07:25 -04:00
jiang1997
d8a8d1fc56
[MLIR][MemRef] Change builders with int alignment params to llvm::MaybeAlign (#159449)
Change remaining OpBuilder methods to use `llvm::MaybeAlign` instead of
`uint64_t` for alignment parameters.

---------

Co-authored-by: Erick Ochoa Lopez <erick.ochoalopez@amd.com>
2025-09-29 09:25:49 -04:00
Erick Ochoa Lopez
8b9c70dcdb
[mlir] Move vector.{to_elements,from_elements} unrolling to VectorUnroll.cpp (#159118)
This PR moves the patterns that unroll vector.to_elements and
vector.from_elements into the file with other vector unrolling
operations. This PR also adds these unrolling patterns into the
`populateVectorUnrollPatterns`. And renames
`populateVectorToElementsLoweringPatterns`
`populateVectorFromElementsLoweringPatterns` to
`populateVectorToElementsUnrollPatterns`
`populateVectorFromElementsUnrollPatterns`.
2025-09-18 12:03:54 -04:00
Jan Patrick Lehr
50f81531b4
[MLIR] Fix compilation after #157771 (#159257)
The original PR broke pretty much all our bots.
Apologies for the noise in the previous PR.
2025-09-17 09:13:44 +02:00
Diego Caballero
7bdd88c1e3
[mlir][Vector] Add patterns to lower vector.shuffle (#157611)
This PR adds patterns to lower `vector.shuffle` with inputs with
different vector sizes more efficiently. The current LLVM lowering for
these cases degenerates to a sequence of `vector.extract` and
`vector.insert` operations. With this PR, the smaller input is promoted
to larger vector size by introducing an extra `vector.shuffle`.
2025-09-16 18:01:30 -07:00
Nishant Patel
0e5c32bd6d
[MLIR][Vector] Add unrolling pattern for vector StepOp (#157752)
This PR adds unrolling pattern for vector.step op to VectorUnroll
transform.
2025-09-16 15:33:08 -07:00
Alan Li
4a094095a4
[MLIR] Make 1-D memref flattening a prerequisite for vector narrow type emulation (#157771)
Addresses:  https://github.com/llvm/llvm-project/issues/115653

We already have utilities to flatten memrefs into 1-D. This change makes
memref flattening a prerequisite for vector narrow type emulation,
ensuring that emulation patterns only need to handle 1-D scenarios.
2025-09-16 20:43:20 +00:00
Andrzej Warzyński
1287ed1fa2
[mlir][vector] Use source as the source argument name (#158258)
This patch updates the following ops to use `source` (instead of
`vector`) as the name for their source argument:
  * `vector.extract`
  * `vector.scalable.extract`
  * `vector.extract_strided_slice`

This change ensures naming consistency with the "builders" for these Ops
that already use the name `source` rather than `vector`. It also
addresses part of:
  * https://github.com/llvm/llvm-project/issues/131602

Specifically, it ensures that we use `source` and `dest` for read and
write operations, respectively (as opposed to `vector` and `dest`).
2025-09-15 21:18:26 +01:00
Erick Ochoa Lopez
b812e3d61a
[mlir][vector] Add LinearizeVectorToElements (#157740)
Co-authored-by: James Newling <james.newling@gmail.com>
2025-09-11 13:58:42 -04:00