[llvm] [SLP]Model single unique value insert + shuffle as splat + select, where profitable (PR #136590)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 21 11:24:44 PDT 2025


alexey-bataev wrote:

> Did you evaluate this alternative?
> 
> ```
> %bv = insertelement poison, %v, 0
> %res = shuffle %vec, %splat, <0, 1, 2,..., VF, pos1 + 1, .., VF,...>
> ```
> 
> This isn't an explicit broadcast, but I'd suspect the TTI could reasonable recognize this for e.g. a vmerge.vxm on RISCV.
> 
> The form chosen here is also reasonable, so don't feel the need to switch course, I'm just asking for my own education.

Yes, tried it, thought it would be better to model it as in the patch and later teach the TTI about dropping the cost for broadcast, if the broadcasted vector is insertelement poison, value, 0.
Select pattern recognition is supported by many target TI, while `<0, 1, 2,..., VF, pos1 + 1, .., VF,...>` is not.

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


More information about the llvm-commits mailing list