[Mlir-commits] [mlir] [mlir] Add vector.{to_elements, from_elements} unrolling to `unrollVectorsInFuncBodies` (PR #159118)
Erick Ochoa Lopez
llvmlistbot at llvm.org
Tue Sep 16 09:13:44 PDT 2025
================
@@ -1495,6 +1495,8 @@ LogicalResult mlir::spirv::unrollVectorsInFuncBodies(Operation *op) {
RewritePatternSet patterns(context);
auto options = vector::UnrollVectorOptions().setNativeShapeFn(
[](auto op) { return mlir::spirv::getNativeVectorShape(op); });
+ vector::populateVectorFromElementsLoweringPatterns(patterns);
+ vector::populateVectorToElementsLoweringPatterns(patterns);
populateVectorUnrollPatterns(patterns, options);
----------------
amd-eochoalo wrote:
It seems like unrolling patterns for vector.from_elements and vector.to_elements could also be added inside `populateVectorUnrollPatterns`. The function `populateVectorUnrollPatterns` is used in several more passes and dialects.
```
mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h:void populateVectorUnrollPatterns(RewritePatternSet &patterns,
mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp: vector::populateVectorUnrollPatterns(
mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp: populateVectorUnrollPatterns(patterns, options);
mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp:void mlir::vector::populateVectorUnrollPatterns(
mlir/lib/Dialect/XeGPU/Transforms/XeGPUBlocking.cpp: vector::populateVectorUnrollPatterns(patterns, vectorOptions);
```
At the moment, I opted not to add them there because the initial `vector.from_elements` pattern was not added there. (When I wrote the `vector.to_elements` pattern I tried to be consistent with `vector.from_elements` and therefore `vector.to_elements` was also not added to `populateVectorUnrollPatterns`.
Happy to move them to this function if reviewers believe it is a good idea.
https://github.com/llvm/llvm-project/pull/159118
More information about the Mlir-commits
mailing list