<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 - [SLP] Missed sum reduction of differences"
href="https://bugs.llvm.org/show_bug.cgi?id=43953">43953</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[SLP] Missed sum reduction of differences
</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>Windows NT
</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>llvm-dev@redking.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>a.bataev@hotmail.com, dtemirbulatov@gmail.com, llvm-bugs@lists.llvm.org, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>Noticed in a from
<a href="https://devblogs.microsoft.com/cppblog/game-performance-improvements-in-visual-studio-2019-version-16-2/">https://devblogs.microsoft.com/cppblog/game-performance-improvements-in-visual-studio-2019-version-16-2/</a>
While the original example does vectorize:
uint32_t TestVectorsEqual(float* Vec0, float* Vec1, float Tolerance = 1e7f)
{
float sum = 0.f;
for (int32_t Component = 0; Component < 4; Component++)
{
float Diff = Vec0[Component] - Vec1[Component];
sum += (Diff >= 0.0f) ? Diff : -Diff;
}
return (sum <= Tolerance) ? 1 : 0;
}
This simpler version fails for some reason (probably costs....):
uint32_t TestVectorsEqual_alt(float* __restrict Vec0, float* __restrict Vec1,
float Tolerance = 1e7f)
{
float sum = 0.f;
for (int32_t Component = 0; Component < 4; Component++)
{
float Diff = Vec0[Component] - Vec1[Component];
sum += Diff;
}
return (sum <= Tolerance) ? 1 : 0;
}
<a href="https://gcc.godbolt.org/z/hG7Ntp">https://gcc.godbolt.org/z/hG7Ntp</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>