<html>
<head>
<base href="https://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 --- - [x86, SSE] insertps chosen when unpcklps would be better"
href="https://llvm.org/bugs/show_bug.cgi?id=27854">27854</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[x86, SSE] insertps chosen when unpcklps would be better
</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>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Forking this off of <a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Code explosion when LoopVectorize vectorizes a loop with a stride of 8 floats"
href="show_bug.cgi?id=27826">bug 27826</a>:
If we have a sequence of insertelements to fill in a vector:
define <4 x float> @goo(float %f0, float %f1, float %f2, float %f3) {
%ins0 = insertelement <4 x float> undef, float %f0, i32 0
%ins1 = insertelement <4 x float> %ins0, float %f1, i32 1
%ins2 = insertelement <4 x float> %ins1, float %f2, i32 2
%ins3 = insertelement <4 x float> %ins2, float %f3, i32 3
ret <4 x float> %ins3
}
We do the optimal thing with SSE2:
$ ./llc -o - inselts.ll
...
unpcklps %xmm3, %xmm1 ## xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
unpcklps %xmm2, %xmm0 ## xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
unpcklps %xmm1, %xmm0 ## xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
retq
The first two instructions are independent, so they can execute in parallel
given enough hardware.
But given the opportunity to use ever more shuffle instructions with each ISA
extension:
$ ./llc -o - inselts.ll -mattr=sse4.1
...
insertps $16, %xmm1, %xmm0 ## xmm0 = xmm0[0],xmm1[0],xmm0[2,3]
insertps $32, %xmm2, %xmm0 ## xmm0 = xmm0[0,1],xmm2[0],xmm0[3]
insertps $48, %xmm3, %xmm0 ## xmm0 = xmm0[0,1,2],xmm3[0]
retq
We now have a sequence of 3 dependent instructions, and each of those
instructions is larger in size too.</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>