[llvm-dev] [RFC] Extending shufflevector for vscale vectors (SVE etc.)

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 5 16:01:37 PST 2020


On Jan 29, 2020, at 4:48 PM, Eli Friedman via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Currently, for scalable vectors, only splat shuffles are allowed; we're considering allowing more different kinds of shuffles.  The issue is, essentially, that a shuffle mask is a simple list of integers, and that isn't enough to express a scalable operation.  For example, concatenating two fixed-length vectors currently looks like this:
> 
> Proposed IR syntax:
> 
> %result = shufflevector <vscale x 4 x i32> %v1, <vscale x 4 x i32> %v2, SHUFFLE_NAME
> 
> Alternatives:
> 
> Instead of extending shufflevector, we could introduce a dedicated intrinsic for each common shuffle.  This is less readable, and makes it harder to leverage existing code that reasons about shuffles.  But it would mean fewer changes to existing code.

Hi Eli,

Did you consider a design point between these two extremes?  You could introduce one new instruction, something like “fixed shuffle vector” that takes two vectors and an enum.  That would keep the structurally (and representationally) different cases as separate instructions, without creating a new instruction per fixed shuffle kind.

Relatedly, how do you foresee canonicalization (in instcombine and inst selection) working for these?  If not for compatibility, it would make sense to canonicalize from shuffle vector to the ‘fixed’ formats, but doing that would probably introduce a bunch of regressions for various targets.

-Chris



More information about the llvm-dev mailing list