llvm-project
llvm-project copied to clipboard
256-bit vector shift by scalar variable is not efficient on AVX
| Bugzilla Link | 15296 |
| Resolution | FIXED |
| Resolved on | Mar 19, 2013 21:34 |
| Version | trunk |
| OS | All |
| CC | @topperc |
fixed in r177478.
patch is submitted for review @ http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130218/166057.html
I'll take this.
test file LLVM trunk will generate the following code on the attached test:
$ llc -mcpu=corei7-avx < test.ll
.file "<stdin>"
.text
.globl shiftInput___vyuunu
.align 16, 0x90
.type shiftInput___vyuunu,@function
shiftInput___vyuunu: # @shiftInput___vyuunu
# BB#0: # %allocas
movl %edi, %ecx
vextractf128 $1, %ymm0, %xmm1
vpextrd $1, %xmm1, %eax
shrl %cl, %eax
vmovd %xmm1, %edx
shrl %cl, %edx
vmovd %edx, %xmm2
vpinsrd $1, %eax, %xmm2, %xmm2
vpextrd $2, %xmm1, %edx
shrl %cl, %edx
vpextrd $1, %xmm0, %eax
vpinsrd $2, %edx, %xmm2, %xmm2
shrl %cl, %eax
vmovd %xmm0, %edx
shrl %cl, %edx
vmovd %edx, %xmm3
vpextrd $3, %xmm1, %edx
shrl %cl, %edx
vpinsrd $3, %edx, %xmm2, %xmm1
vpinsrd $1, %eax, %xmm3, %xmm2
vpextrd $2, %xmm0, %eax
shrl %cl, %eax
vpinsrd $2, %eax, %xmm2, %xmm2
vpextrd $3, %xmm0, %eax
# kill: CL<def> CL<kill> ECX<kill>
shrl %cl, %eax
vpinsrd $3, %eax, %xmm2, %xmm0
vinsertf128 $1, %xmm1, %ymm0, %ymm0
ret
.Ltmp0:
.size shiftInput___vyuunu, .Ltmp0-shiftInput___vyuunu
.section ".note.GNU-stack","",@progbits
which is considered really efficient as the following sequence should be generated instead:
.file "<stdin>"
.text
.globl shiftInput___vyuunu
.align 16, 0x90
.type shiftInput___vyuunu,@function
shiftInput___vyuunu: # @shiftInput___vyuunu
# BB#0: # %allocas
vmovd %edi, %xmm1
vextractf128 $1, %ymm0, %xmm2
vpsrld %xmm1, %xmm2, %xmm2
vpsrld %xmm1, %xmm0, %xmm0
vinsertf128 $1, %xmm2, %ymm0, %ymm0
ret
.Ltmp0:
.size shiftInput___vyuunu, .Ltmp0-shiftInput___vyuunu
.section ".note.GNU-stack","",@progbits
assigned to @topperc