<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - some shuffles get decomposed to insert/extract sequence with avx"
href="http://llvm.org/bugs/show_bug.cgi?id=15872">15872</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>some shuffles get decomposed to insert/extract sequence with avx
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>sroland@vmware.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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 <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - shuffle patterns not recognized with avx"
href="show_bug.cgi?id=12413">http://llvm.org/bugs/show_bug.cgi?id=12413</a> but that
one was fixed.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>