llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

AVX-512: Shuffle from <16 x i32> to <4 x i32> should be optimized

Open delena opened this issue 9 years ago • 3 comments

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

delena avatar Dec 22 '16 10:12 delena

Fixed in rL365050

foo: vmovaps .LCPI0_0(%rip), %xmm1 # xmm1 = [0,4,8,12] vpermps %zmm0, %zmm1, %zmm0 vzeroupper retq

RKSimon avatar Jul 04 '19 08:07 RKSimon

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

RKSimon avatar Jun 16 '19 19:06 RKSimon

assigned to @RKSimon

delena avatar Dec 22 '16 10:12 delena