AVX-512: Shuffle from <16 x i32> to <4 x i32> should be optimized
| Bugzilla Link | 31451 |
| Resolution | FIXED |
| Resolved on | Jul 04, 2019 01:18 |
| Version | trunk |
| OS | All |
| CC | @RKSimon,@ZviRackover |
| Fixed by commit(s) | r365050 |
Extended Description
define <4 x i32> @foo(<16 x i32> %v) { %strided.vec = shufflevector <16 x i32> %v, <16 x i32> undef, <4 x i32> <i32 0, i32 4, i32 8, i32 12> ret <4 x i32>%strided.vec } This shuffle requires 1 instruction on AVX-512. The output of llc: vextracti32x4 $1, %zmm0, %xmm1 vmovd %xmm1, %eax vpinsrd $1, %eax, %xmm0, %xmm1 vextracti32x4 $2, %zmm0, %xmm2 vmovd %xmm2, %eax vpinsrd $2, %eax, %xmm1, %xmm1 vextracti32x4 $3, %zmm0, %xmm0 vmovd %xmm0, %eax vpinsrd $3, %eax, %xmm1, %xmm0
Fixed in rL365050
foo: vmovaps .LCPI0_0(%rip), %xmm1 # xmm1 = [0,4,8,12] vpermps %zmm0, %zmm1, %zmm0 vzeroupper retq
Current codegen: https://gcc.godbolt.org/z/w-py72
.LCPI0_0: .quad 17179869184 # 0x400000000 foo: # @foo vextractf128 $1, %ymm0, %xmm1 vunpcklps %xmm1, %xmm0, %xmm1 # xmm1 = xmm0[0],xmm1[0],xmm0[1],xmm1[1] vextractf64x4 $1, %zmm0, %ymm0 vbroadcastsd .LCPI0_0(%rip), %ymm2 # ymm2 = [17179869184,17179869184,17179869184,17179869184] vpermps %ymm0, %ymm2, %ymm0 vblendps $12, %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0,1],xmm0[2,3] vzeroupper retq
assigned to @RKSimon