[Mlir-commits] [mlir] [mlir][VectorOp] Move VectorMaskOpConversionBase template to header (NFC) (PR #69341)

Benjamin Maxwell llvmlistbot at llvm.org
Tue Oct 17 12:19:33 PDT 2023


MacDue wrote:

> > > LG but just a design comment. If you have a chance, make sure you lower the vector mask before we lower to LLVM when possible. Lowering both at the same time can get unnecessarily complicated.
> > 
> > 
> > Currently I'm doing the conversion within the lowering to LLVM, but with multiple patterns (as there's not another obvious place to put it). So it goes:
> > 
> > 1. `vector.mask { vector.outerproduct ... }` or `vector.outerproduct`
> > 2. -> `arm_sme.outerproduct ... %lhsMask, %rhsMask ...` (rewrite 1: to intermediate operand-masked arm_sme op)
> > 3. -> SME intrinsic (rewrite 2)
> > 
> > Which avoids one big rewrite.
> 
> Why don't you move #2 this to the vector to SME lowering? You can create another `ConvertMaskOpTo...`.

Currently, the lowering requires the rewrites from `LowerVectorMask` to apply to the `vector.create_mask` before it can match.

For example, in the matmul, you get a `vector.create_mask` like:
```
%mask vector.create_mask %c1, %dimA, %dimB : vector<1x[4]x[4]xi1>
vector.extract %mask[0] : vector<[4]x[4]xi1>
```
There is no fold for an extract from a create_mask like that, but if you run `-convert-vector-to-llvm` it will unroll the leading dim of the `create_mask`, which then allows folding way the extracts. That makes getting the masks for the outer product simpler.

I did write a fold for an extract from `create_mask`, but dropped it since you can rely on this unrolling in `-convert-vector-to-llvm`. I could submit a patch for that though, and that'd allow moving rewrite 1 to `-convert-vector-to-arm-sme`. What do you think?




https://github.com/llvm/llvm-project/pull/69341


More information about the Mlir-commits mailing list