<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 - Compiler not generating hadd/hsub instructions for simple pattern"
href="https://bugs.llvm.org/show_bug.cgi?id=34110">34110</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compiler not generating hadd/hsub instructions for simple pattern
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>douglas_yung@playstation.sony.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>After commit r310260, the following code no longer generates horizontal
add/subtract instructions when compiled with optimizations enabled:
__m128 hadd2ps(__m128 a, __m128 b)
{
return (__m128){ a[0] + a[1], a[2] + a[3], b[0] + b[1], b[2] + b[3] };
}
Prior to r310260, the code above when compiled would generate the following x86
assembly:
clang -S -O2 repro.cpp -mavx -o -:
.cfi_startproc
# BB#0: # %entry
vhaddps %xmm1, %xmm0, %xmm0
retq
But starting with r310260, the compiler no longer generates the horizontal add
instruction:
clang -S -O2 repro.cpp -mavx -o -:
.cfi_startproc
# BB#0: # %entry
vpermilps $232, %xmm0, %xmm2 # xmm2 = xmm0[0,2,2,3]
vpermilps $237, %xmm0, %xmm0 # xmm0 = xmm0[1,3,2,3]
vpermilpd $1, %xmm1, %xmm3 # xmm3 = xmm1[1,0]
vaddps %xmm0, %xmm2, %xmm0
vmovshdup %xmm1, %xmm2 # xmm2 = xmm1[1,1,3,3]
vaddss %xmm2, %xmm1, %xmm2
vpermilps $231, %xmm1, %xmm1 # xmm1 = xmm1[3,1,2,3]
vaddss %xmm1, %xmm3, %xmm1
vinsertps $32, %xmm2, %xmm0, %xmm0 # xmm0 =
xmm0[0,1],xmm2[0],xmm0[3]
vinsertps $48, %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0,1,2],xmm1[0]
retq
This suboptimal codegen also applies to the horizontal subtraction case.</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>