<64 x i8> reverse shuffle should be optimized
| Bugzilla Link | 31470 |
| Resolution | FIXED |
| Resolved on | Jan 07, 2017 10:03 |
| Version | trunk |
| OS | Windows NT |
| CC | @RKSimon,@ZviRackover |
Extended Description
The reverse shuffle:
define <64 x i8> @foo(<64 x i8> %src512) { %V512 = shufflevector <64 x i8> %src512, <64 x i8> undef, <64 x i32> <i32 63, i32 62, i32 61, i32 60, i32 59, i32 58, i32 57, i32 56, i32 55, i32 54, i32 53, i32 52, i32 51, i32 50, i32 49, i32 48, i32 47, i32 46, i32 45, i32 44, i32 43, i32 42, i32 41, i32 40, i32 39, i32 38, i32 37, i32 36, i32 35, i32 34, i32 33, i32 32, i32 31, i32 30, i32 29, i32 28, i32 27, i32 26, i32 25, i32 24, i32 23, i32 22, i32 21, i32 20, i32 19, i32 18, i32 17, i32 16, i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0> ret <64 x i8> %V512 }
The code, generated for skylake-AVX512: vmovdqu8 .LCPI0_0(%rip), %ymm1 # ymm1 = [15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0] vpshufb %ymm1, %ymm0, %ymm2 vperm2i128 $1, %ymm0, %ymm2, %ymm2 # ymm2 = ymm2[2,3,0,1] vextracti64x4 $1, %zmm0, %ymm0 vpshufb %ymm1, %ymm0, %ymm0 vperm2i128 $1, %ymm0, %ymm0, %ymm0 # ymm0 = ymm0[2,3,0,1] vinserti64x4 $1, %ymm2, %zmm0, %zmm0
Should be done in 2 instructions: vpshufb %zmm - reverse elements inside 128-bit lanes vperm2i128 - put 4 128-bit lanes in reverse order
Fixed in rL291347
Added a test for this at rL290544 - vbmi does a good job with it but not much else.
This should be simple to do by adding 512-bit vector support to lowerShuffleAsRepeatedMaskAndLanePermute