[LLVMbugs] [Bug 15872] New: some shuffles get decomposed to insert/extract sequence with avx
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Apr 30 12:11:22 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=15872
Bug ID: 15872
Summary: some shuffles get decomposed to insert/extract
sequence with avx
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: sroland at vmware.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Some rather simple but non-native shuffles produce completely horrendous code
because they get decomposed to single element inserts/extracts.
Here's an example:
define <4 x i32> @shuf(<8 x i32> %inval, <4 x i32>* %ptr1) {
entry:
%0 = shufflevector <8 x i32> %inval, <8 x i32> %inval, <4 x i32> <i32 0, i32
1, i32 4, i32 5>
%1 = shufflevector <8 x i32> %inval, <8 x i32> %inval, <4 x i32> <i32 2, i32
3, i32 6, i32 7>
store <4 x i32> %0, <4 x i32>* %ptr1, align 16
ret <4 x i32> %1
This generates:
vpextrd $1, %xmm0, %eax
vmovd %xmm0, %ecx
vmovd %ecx, %xmm1
vpinsrd $1, %eax, %xmm1, %xmm2
vextractf128 $1, %ymm0, %xmm1
vmovd %xmm1, %eax
vpinsrd $2, %eax, %xmm2, %xmm2
vpextrd $1, %xmm1, %eax
vpinsrd $3, %eax, %xmm2, %xmm2
vmovdqa %xmm2, (%rdi)
vpextrd $3, %xmm0, %eax
vpextrd $2, %xmm0, %ecx
vmovd %ecx, %xmm0
vpinsrd $1, %eax, %xmm0, %xmm0
vpextrd $2, %xmm1, %eax
vpinsrd $2, %eax, %xmm0, %xmm0
vpextrd $3, %xmm1, %eax
vpinsrd $3, %eax, %xmm0, %xmm0
vzeroupper
ret
which is quite obviously a disaster.
(With float instead of i32 values it will produce
vpshufd $1, %xmm0, %xmm1
vinsertps $16, %xmm1, %xmm0, %xmm2
vextractf128 $1, %ymm0, %xmm1
vinsertps $32, %xmm1, %xmm2, %xmm2
vpshufd $1, %xmm1, %xmm3
vinsertps $48, %xmm3, %xmm2, %xmm2
vmovaps %xmm2, (%rdi)
vpshufd $3, %xmm0, %xmm2
vmovhlps %xmm0, %xmm0, %xmm0
vinsertps $16, %xmm2, %xmm0, %xmm0
vmovhlps %xmm1, %xmm1, %xmm2
vinsertps $32, %xmm2, %xmm0, %xmm0
vpshufd $3, %xmm1, %xmm1
vinsertps $48, %xmm1, %xmm0, %xmm0
vzeroupper
ret
which is not really much better neither.)
But this should really just be (or something similar, there's quite some
options, for instance using vshufps):
vextractf128 $1, %ymm0, %xmm1
vmovlhps %xmm0, %xmm1, %xmm2
vmovaps %xmm2, (%rdi)
vunpckhpd %xmm0, %xmm1, %xmm0
vzeroupper
ret
This is somewhat similar to http://llvm.org/bugs/show_bug.cgi?id=12413 but that
one was fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130430/6370ad7b/attachment.html>
More information about the llvm-bugs
mailing list