[RISCV] Lower vector shuffles to vrgather operations
authorFraser Cormack <fraser@codeplay.com>
Thu, 15 Apr 2021 09:06:11 +0000 (10:06 +0100)
committerFraser Cormack <fraser@codeplay.com>
Mon, 19 Apr 2021 10:13:13 +0000 (11:13 +0100)
commitc9a93c3e0128e3f35620e69d6dad200cd9e37d3c
treeb848dcd77555e064399afdb65c4b319a27ddd129
parent62ee638a870002760be515c6239592a2a950d4dd
[RISCV] Lower vector shuffles to vrgather operations

This patch extends the lowering of RVV fixed-length vector shuffles to
avoid the default stack expansion and instead lower to vrgather
instructions.

For "permute"-style shuffles where one vector is swizzled, we can lower
to one vrgather. For shuffles involving two vector operands, we lower to
one unmasked vrgather (or splat, where appropriate) followed by a masked
vrgather which blends in the second half.

On occasion, when it's not possible to create a legal BUILD_VECTOR for
the indices, we use vrgatherei16 instructions with 16-bit index types.

For 8-bit element vectors where we may have indices over 255, we have a
fairly blunt fallback to the stack expansion to avoid custom-splitting
of the vector types.

To enable the selection of masked vrgather instructions, this patch
extends the various RISCVISD::VRGATHER nodes to take a passthru operand.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D100549
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-shuffles.ll
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-shuffles.ll