[X86] Enable v16i8/v32i8/v64i8 rotation on AVX512 targets
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 15 Dec 2021 11:17:10 +0000 (11:17 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 15 Dec 2021 11:17:45 +0000 (11:17 +0000)
commit36b0325c442a3669c2eb2c6fcaeb2cb57445c851
tree6e87c594495f83667b05a9d1415c887cfb5e2aab
parent481de0ed804c8547fbfac5fe88d109c692c8d117
[X86] Enable v16i8/v32i8/v64i8 rotation on AVX512 targets

We currently rely on generic promotion to vXi16/vXi32 types for rotation lowering on various AVX512 targets.

We can more efficiently perform this by making use of the shl(unpack(x,x),amt) style pattern that we already use for vXi8 rotation by splat amounts, either by widening to a larger vector type or unpacking lo/hi halves of the subvectors so we can access whatever vXi16/vXi32 per-element shifts are supported.

This uncovered an issue in the supportedVectorShiftWithImm/supportedVectorVarShift legality checkers which was using hasAVX512() instead of useAVX512Regs() to detect support for 512-bit vector shifts.

NOTE: I'm actually hoping to eventually reuse this code for shl(unpack(y,x),amt) funnel shift lowering (vXi8 and wider), but initially I just want to ensure we have efficient ISD::ROTL lowering for all targets.

Differential Revision: https://reviews.llvm.org/D115180
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/min-legal-vector-width.ll
llvm/test/CodeGen/X86/vector-fshl-rot-128.ll
llvm/test/CodeGen/X86/vector-fshl-rot-256.ll
llvm/test/CodeGen/X86/vector-fshl-rot-512.ll
llvm/test/CodeGen/X86/vector-fshr-rot-128.ll
llvm/test/CodeGen/X86/vector-fshr-rot-256.ll
llvm/test/CodeGen/X86/vector-fshr-rot-512.ll
llvm/test/CodeGen/X86/vector-rotate-128.ll
llvm/test/CodeGen/X86/vector-rotate-256.ll
llvm/test/CodeGen/X86/vector-rotate-512.ll