<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 - Vectorized fp min/max reduction loop uses minnum/maxnum for horizontal reduction, but not loop body"
href="https://bugs.llvm.org/show_bug.cgi?id=43574">43574</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Vectorized fp min/max reduction loop uses minnum/maxnum for horizontal reduction, but not loop body
</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>All
</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>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>craig.topper@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>For a min/max reduction loop, the vectorizer adds fast math flags to the
fcmp/select for the horizontal reduction after the loop. But the selects in the
loop don't have fastmath flags. This leads to InstCombine creating
fmaxnum/fminnum intrinsics for the horizontal reduction. X86 codegens both the
loop body and the horizontal reduction to the FP min/max instructions so the
difference didn't end up mattering. It just looked inconsistent.
clang -Ofast -march=skylake-avx512
float a[1024];
float foo() {
float min = 0.0;
for (int i = 0; i != 1024; ++i)
min = min < a[i] ? min : a[i];
return min;
}
<a href="https://godbolt.org/z/AMWYWm">https://godbolt.org/z/AMWYWm</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>