Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ void populateVectorBitCastLoweringPatterns(RewritePatternSet &patterns,
/// n > 1.
void populateVectorRankReducingFMAPattern(RewritePatternSet &patterns);

/// Populate patterns to rewrite sequences of `vector.to_elements` +
/// `vector.from_elements` operations into a tree of `vector.shuffle`
/// operations.
void populateVectorToFromElementsToShuffleTreePatterns(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you envisage this being used more directly as a pattern, or as the pass lower-vector-to-from-elements-to-shuffle-tree? I suppose that if it were to be used only as a pass, it would be more efficient if implemented directly as a walk over all ops (just a thought, not a request for change).

Copy link
Contributor Author

@dcaballe dcaballe Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different projects may apply it in different ways... that's mostly why I followed the same structure as we follow for other transformations...

RewritePatternSet &patterns, PatternBenefit benefit = 1);

} // namespace vector
} // namespace mlir

#endif // MLIR_DIALECT_VECTOR_TRANSFORMS_LOWERINGPATTERNS_H
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/Vector/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef MLIR_DIALECT_VECTOR_TRANSFORMS_PASSES_H_
#define MLIR_DIALECT_VECTOR_TRANSFORMS_PASSES_H_

#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h"
#include "mlir/Pass/Pass.h"

Expand Down
5 changes: 5 additions & 0 deletions mlir/include/mlir/Dialect/Vector/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ def LowerVectorMultiReduction : Pass<"lower-vector-multi-reduction", "func::Func
];
}

def LowerVectorToFromElementsToShuffleTree
: Pass<"lower-vector-to-from-elements-to-shuffle-tree", "func::FuncOp"> {
let summary = "Lower `vector.to_elements` and `vector.from_elements` to a tree of `vector.shuffle` operations";
}

#endif // MLIR_DIALECT_VECTOR_TRANSFORMS_PASSES
1 change: 1 addition & 0 deletions mlir/lib/Dialect/Vector/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_mlir_dialect_library(MLIRVectorTransforms
LowerVectorScan.cpp
LowerVectorShapeCast.cpp
LowerVectorStep.cpp
LowerVectorToFromElementsToShuffleTree.cpp
LowerVectorTransfer.cpp
LowerVectorTranspose.cpp
SubsetOpInterfaceImpl.cpp
Expand Down
Loading
Loading