AVX-512: <64 x i8> shuffle is scalarized in the CodeGen
| Bugzilla Link | 33784 |
| Resolution | FIXED |
| Resolved on | Jul 30, 2017 02:49 |
| Version | trunk |
| OS | Windows NT |
| CC | @RKSimon,@ZviRackover |
Extended Description
define <16 x i8> @foo(<64 x i8> %x) { %res = shufflevector <64 x i8> %x, <64 x i8> undef, <16 x i32> <i32 1, i32 5, i32 9, i32 13, i32 17, i32 21, i32 25, i32 29, i32 33, i32 37, i32 41, i32 45, i32 49, i32 53, i32 57, i32 61> ret <16 x i8> %res }
llc -mcpu=skx < test.ll
vpextrb $5, %xmm0, %eax
vpextrb $1, %xmm0, %ecx
vmovd %ecx, %xmm1
vpinsrb $1, %eax, %xmm1, %xmm1
vpextrb $9, %xmm0, %eax
vpinsrb $2, %eax, %xmm1, %xmm1
vpextrb $13, %xmm0, %eax
vpinsrb $3, %eax, %xmm1, %xmm1
vextracti32x4 $1, %zmm0, %xmm2
vpextrb $1, %xmm2, %eax
vpinsrb $4, %eax, %xmm1, %xmm1
vpextrb $5, %xmm2, %eax
vpinsrb $5, %eax, %xmm1, %xmm1
vpextrb $9, %xmm2, %eax
vpinsrb $6, %eax, %xmm1, %xmm1
vpextrb $13, %xmm2, %eax
vpinsrb $7, %eax, %xmm1, %xmm1
vextracti32x4 $2, %zmm0, %xmm2
vpextrb $1, %xmm2, %eax
vpinsrb $8, %eax, %xmm1, %xmm1
vpextrb $5, %xmm2, %eax
vpinsrb $9, %eax, %xmm1, %xmm1
vpextrb $9, %xmm2, %eax
vpinsrb $10, %eax, %xmm1, %xmm1
vpextrb $13, %xmm2, %eax
vpinsrb $11, %eax, %xmm1, %xmm1
vextracti32x4 $3, %zmm0, %xmm0
vpextrb $1, %xmm0, %eax
vpinsrb $12, %eax, %xmm1, %xmm1
vpextrb $5, %xmm0, %eax
vpinsrb $13, %eax, %xmm1, %xmm1
vpextrb $9, %xmm0, %eax
vpinsrb $14, %eax, %xmm1, %xmm1
vpextrb $13, %xmm0, %eax
vpinsrb $15, %eax, %xmm1, %xmm0
Fix in r309108
Hi Jatin,
https://reviews.llvm.org/D35700 is also intended for fixing this. i should have posted it here earlier. But seems like your patch can be also good for more cases.
Here is a generic fix for this, kindly review it.
https://reviews.llvm.org/D35788
Thanks, Jatin
For SKX can we do any better than this? vpsrlw $8, %zmm0, %zmm0 vpmovdb %zmm0, %xmm0
Looks reasonable to me.
For SKX can we do any better than this? vpsrlw $8, %zmm0, %zmm0 vpmovdb %zmm0, %xmm0
This works for KNL since argument type v64i8 is broken down to two v32i8 as v64i8 is not a legal type for KNL, but for SXK v64i8 is legal type hense during SelectionDABBuilder::visitShuffleVector we do not generate vector_shuffle for SKX.
Looks like we need something like a generic lowerBuildVectorAsShuffleAndTrunc helper.