[Mlir-commits] [mlir] [mlir][vector] Add an eliminate-vector-masks pass (PR #226517)
Federico Bruzzone
llvmlistbot at llvm.org
Sat Sep 26 04:21:16 PDT 2026
================
@@ -11,6 +11,30 @@
include "mlir/Pass/PassBase.td"
+def EliminateVectorMasks : Pass<"eliminate-vector-masks", "func::FuncOp"> {
+ let summary = "Replace masks that are provably all-true with constant masks";
+ let description = [{
+ Rewrites `vector.create_mask` operations that can be proven all-true into
+ `vector.constant_mask`. Canonicalization then folds those away, turning a
+ masked transfer into an unmasked one.
+
+ A mask dimension is all-true when its size is at least the size of the
+ corresponding vector dimension. Sizes are bounded with
+ `ValueBoundsOpInterface`, so sizes derived from a loop, such as
+ `%dim - %iv`, can be proven too.
+
+ Proving a scalable dimension needs the range of `vscale`: pass `vscale-min`
+ and `vscale-max` when it is known for the target (1 and 16 for SVE, say).
+ Without a range, only fixed-size dimensions can be proven.
+ }];
+ let options = [
+ Option<"vscaleMin", "vscale-min", "unsigned", /*default=*/"0",
+ "Minimum possible value of vscale, or 0 when unknown.">,
+ Option<"vscaleMax", "vscale-max", "unsigned", /*default=*/"0",
+ "Maximum possible value of vscale, or 0 when unknown.">,
+ ];
----------------
FedericoBruzzone wrote:
Since a real vscale is never `0` this is probably fine, but should the error message be clearer for someone who explicitly typed `vscale-min=0`, for instance?
https://github.com/llvm/llvm-project/pull/226517
More information about the Mlir-commits
mailing list