<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - Failure to optimize small vectors from using s"
href="https://bugs.llvm.org/show_bug.cgi?id=52057">52057</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Failure to optimize small vectors from using s
</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>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gabravier@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>typedef char V __attribute__((vector_size(2)));
V foo(V v)
{
v[(V){}[0]] <<= 1;
return v;
}
Code such as this seems to be very badly optimized for all targets that have
SIMD.
With -O3, Clang outputs this:
.LCPI0_0:
.byte 0 # 0x0
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
.byte 255 # 0xff
foo(char __vector(2)): # @foo(char __vector(2))
movd xmm0, edi
movdqa xmmword ptr [rsp - 24], xmm0
mov al, byte ptr [rsp - 24]
add al, al
movzx eax, al
movd xmm1, eax
pxor xmm2, xmm2
punpcklbw xmm1, xmm2 # xmm1 =
xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3],xmm1[4],xmm2[4],xmm1[5],xmm2[5],xmm1[6],xmm2[6],xmm1[7],xmm2[7]
pand xmm0, xmmword ptr [rip + .LCPI0_0]
por xmm0, xmm1
movd eax, xmm0
ret
GCC outputs this:
foo(char __vector(2)):
movsx edx, dil
mov eax, edi
add edx, edx
mov al, dl
ret</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>