[llvm] [RISCV] Lower (vector_interleave X, undef) to (vzext_vl X). (PR #87283)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 14:40:31 PDT 2024


preames wrote:

> And maybe ` (vector_interleave undef, X)` to `(vsll (vzext_vl X) sew_of_x)` for a separate patch?

I happened to be looking at this code today, and had a similar realization. If anyone has interest, I think this generalizes significantly.  

This tactic can be generalized for an entire family of shuffles of the form:
* <a0, zero, a1, zero> -- this case
* <zero, a0, zero, a1> -- the vwsll case (also the one kito points out)
* <a0, zero, zero, zero, a1, zero, zero, zero> -- the zext.vf4 case

And the VWADD is just a specialization of the ISD::SELECT case when alternating lanes are zero in the two inputs.  

Interestingly, the recursive reasoning would *nearly* make the special case two argument form redundant.  The only bit left is the decision to "commit" undef to be zero.  

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


More information about the llvm-commits mailing list