<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 - Suboptimal auto vectorized code with accumulator"
href="https://bugs.llvm.org/show_bug.cgi?id=51746">51746</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Suboptimal auto vectorized code with accumulator
</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>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>typedef int v4si __attribute__ ((vector_size (16)));
int
test1 (int acc, v4si v1, v4si v2, v4si v3, v4si v4)
{
acc &= v1[0] & v1[1] & v1[2] & v1[3];
acc &= v2[0] & v2[1] & v2[2] & v2[3];
acc &= v3[0] & v3[1] & v3[2] & v3[3];
acc &= v4[0] & v4[1] & v4[2] & v4[3];
return acc;
}
GGC -O3:
test1(int, int __vector(4), int __vector(4), int __vector(4), int __vector(4)):
pand xmm0, xmm1
pand xmm2, xmm3
pand xmm2, xmm0
pshufd xmm0, xmm2, 85
movd edx, xmm2
movd eax, xmm0
movdqa xmm0, xmm2
and eax, edx
punpckhdq xmm0, xmm2
pshufd xmm2, xmm2, 255
and eax, edi
movd edx, xmm0
and edx, eax
movd eax, xmm2
and eax, edx
ret
Clang -O3:
test1(int, int __vector(4), int __vector(4), int __vector(4), int __vector(4)):
# @test1(int, int __vector(4), int __vector(4), int
__vector(4), int __vector(4))
movd eax, xmm1
pshufd xmm4, xmm1, 85 # xmm4 = xmm1[1,1,1,1]
movd ecx, xmm4
and ecx, eax
pshufd xmm4, xmm1, 238 # xmm4 = xmm1[2,3,2,3]
movd eax, xmm4
and eax, ecx
pshufd xmm1, xmm1, 255 # xmm1 = xmm1[3,3,3,3]
movd ecx, xmm1
movd edx, xmm2
pshufd xmm1, xmm2, 85 # xmm1 = xmm2[1,1,1,1]
movd esi, xmm1
and esi, ecx
and esi, edx
pshufd xmm1, xmm2, 238 # xmm1 = xmm2[2,3,2,3]
movd ecx, xmm1
and ecx, esi
pshufd xmm1, xmm2, 255 # xmm1 = xmm2[3,3,3,3]
movd edx, xmm1
and edx, ecx
movd ecx, xmm3
pshufd xmm1, xmm3, 85 # xmm1 = xmm3[1,1,1,1]
movd esi, xmm1
and esi, ecx
pshufd xmm1, xmm3, 238 # xmm1 = xmm3[2,3,2,3]
movd ecx, xmm1
and ecx, esi
pshufd xmm1, xmm3, 255 # xmm1 = xmm3[3,3,3,3]
movd esi, xmm1
and esi, ecx
pshufd xmm1, xmm0, 238 # xmm1 = xmm0[2,3,2,3]
pand xmm1, xmm0
pshufd xmm0, xmm1, 85 # xmm0 = xmm1[1,1,1,1]
pand xmm0, xmm1
movd ecx, xmm0
and eax, edi
and eax, ecx
and eax, edx
and eax, esi
ret
Codegen: <a href="https://godbolt.org/z/Y86fodv5j">https://godbolt.org/z/Y86fodv5j</a></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>