[llvm] [RISCV] Combine vslidedown_vl with known VL to a smaller LMUL (PR #66267)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 11:28:36 PDT 2023


michaelmaitland wrote:

This optimization increases the number of dynamic instructions in the case that other instructions prefer to use the larger LMUL:

```
vsetivli zero, 1, e16, m2, ta, ma
vslidedown.vx v8, v8, a0
// Instructions that want m2
// ...
```
gets optimized to
```
vsetivli zero, 1, e16, m1, ta, ma
vslidedown.vx v8, v8, a0
vsetivli zero, 1, e16, m2, ta, ma
// Instructions that want m2
// ...
```

If this sequence is in a loop, then the effect of this is magnified. Going from M8, M4, or M2 to a smaller LMUL will likely see an improvement that outweighs the cost of the extra vsetivli. However, it is less clear whether going from M1, MF2, or MF4 will outweigh the cost. Should we consider only doing this for LMUL that we are confident bring benefit?

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


More information about the llvm-commits mailing list