Skip to content

Commit 1d50073

Browse files
authored
Bring MLIR SLP-vectorizer (#7)
Add MLIR SLP vectorizer to test in Wave. I hope it will eventually go upstream but for now let's keep it there. llvm/llvm-project#140469 Signed-off-by: Ivan Butygin <[email protected]>
1 parent 164c9af commit 1d50073

File tree

4 files changed

+2378
-0
lines changed

4 files changed

+2378
-0
lines changed

include/water/Transforms/Passes.td

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,24 @@ def WaterCheckStaticAssertionsPass : Pass<"water-check-static-assertions"> {
3838
let summary = "Fail if the IR contains a known-false assertion.";
3939
}
4040

41+
def WaterGreedySLPVectorizer : Pass<"water-greedy-slp-vectorizer"> {
42+
let summary = "SLP Vectorizer Pass";
43+
let description = [{
44+
This pass implements the SLP (Superword Level Parallelism) vectorizer.
45+
It detects consecutive operations that can be put together into vector
46+
operations. The pass works bi-directionaly, starting from reads or stores,
47+
in search of scalars to combine.
48+
49+
This is greedy vectorizer, it doesn't have any cost model (yet) and it tries
50+
to create vector ops if we have at least 2 potential ops.
51+
}];
52+
let dependentDialects = ["mlir::vector::VectorDialect"];
53+
54+
let options = [
55+
Option<"maxVectorBitwidth", "max-vector-bitwidth", "unsigned",
56+
/*default=*/"std::numeric_limits<unsigned>::max()",
57+
"Maximum supported vector bitwidth">,
58+
];
59+
}
60+
4161
#endif // WATER_PASSES

lib/Transforms/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_mlir_dialect_library(MLIRWaterTransforms
22
AccessCheckers.cpp
33
CheckStaticAssertions.cpp
4+
SLPVectorizer.cpp
45

56
ADDITIONAL_HEADER_DIRS
67
${PROJECT_SOURCE_DIR}/include/water
@@ -16,6 +17,8 @@ add_mlir_dialect_library(MLIRWaterTransforms
1617
MLIRIR
1718
MLIRMemRefDialect
1819
MLIRPass
20+
MLIRRewrite
21+
MLIRTransformUtils
1922
MLIRVectorDialect
2023
MLIRWaterAnalysis
2124
)

0 commit comments

Comments
 (0)