<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 generating inefficient code for some horizontal add/sub patterns after r334958"
href="https://bugs.llvm.org/show_bug.cgi?id=37882">37882</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compiler generating inefficient code for some horizontal add/sub patterns after r334958
</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 the upstream change r334958, the compiler is no longer efficiently
optimizing a certain horizontal add/sub pattern. Consider the following code:
/* test.cpp */
#include <x86intrin.h>
__attribute__((noinline))
__m256d add_pd_001(__m256d a, __m256d b) {
return (__m256d){ a[0] + a[1], b[0] + b[1], a[2] + a[3], b[2] + b[3] };
}
If you build the above code using "-S -O2 -march=bdver2 test.cpp" with a
compiler prior to r334958, the compiler generates just one horizontal add
instruction for the function add_pd_001():
vhaddpd %ymm1, %ymm0, %ymm0
The same function when built with r334958 or later now produces the following
assembly:
vhaddpd %xmm1, %xmm0, %xmm2
vextractf128 $1, %ymm1, %xmm1
vextractf128 $1, %ymm0, %xmm0
vhaddpd %xmm1, %xmm0, %xmm0
vinsertf128 $1, %xmm0, %ymm2, %ymm0
Horizontal subtraction is also affected similarly. If you replace the '+' with
'-' in the original example, you will see a similar change in the codegen after
r334958.</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>