<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 (R)SQRT codegen"
href="https://bugs.llvm.org/show_bug.cgi?id=48479">48479</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Suboptimal (R)SQRT codegen
</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>Backend: X86
</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>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>#include <array>
#include <cmath>
#include <numeric>
float Distance(std::array<float, 16> diffs) {
float dist = std::accumulate(diffs.begin(), diffs.end(), 0.0f);
dist = std::sqrt(dist);
return dist;
}
Clant trunk -Ofast -mavx2
.LCPI0_0:
.long 0xbf000000 # float -0.5
.LCPI0_1:
.long 0xc0400000 # float -3
.LCPI0_2:
.long 0x7fffffff # float NaN
.LCPI0_3:
.long 0x00800000 # float 1.17549435E-38
Distance(std::array<float, 16ul>): # @Distance(std::array<float, 16ul>)
vmovups ymm0, ymmword ptr [rsp + 8]
vaddps ymm0, ymm0, ymmword ptr [rsp + 40]
vextractf128 xmm1, ymm0, 1
vaddps xmm0, xmm0, xmm1
vpermilpd xmm1, xmm0, 1 # xmm1 = xmm0[1,0]
vaddps xmm0, xmm0, xmm1
vmovshdup xmm1, xmm0 # xmm1 = xmm0[1,1,3,3]
vaddss xmm0, xmm0, xmm1
vrsqrtss xmm1, xmm0, xmm0
vmulss xmm2, xmm0, xmm1
vmulss xmm3, xmm2, dword ptr [rip + .LCPI0_0]
vmulss xmm1, xmm2, xmm1
vaddss xmm1, xmm1, dword ptr [rip + .LCPI0_1]
vmulss xmm1, xmm3, xmm1
vbroadcastss xmm2, dword ptr [rip + .LCPI0_2] # xmm2 = [NaN,NaN,NaN,NaN]
vandps xmm0, xmm0, xmm2
vcmpltss xmm0, xmm0, dword ptr [rip + .LCPI0_3]
vandnps xmm0, xmm0, xmm1
vzeroupper
ret
ICC 19 -Ofast -mavx2
Distance(std::array<float, 16ul>):
vmovups ymm0, YMMWORD PTR [8+rsp] #141.42
vaddps ymm1, ymm0, YMMWORD PTR [40+rsp] #134.5
vextractf128 xmm2, ymm1, 1 #134.5
vaddps xmm3, xmm1, xmm2 #134.5
vmovhlps xmm4, xmm3, xmm3 #134.5
vaddps xmm5, xmm3, xmm4 #134.5
vshufps xmm6, xmm5, xmm5, 245 #134.5
vaddss xmm0, xmm5, xmm6 #134.5
vsqrtss xmm0, xmm0, xmm0 #464.12
vzeroupper #8.10
ret #8.10
rsqrt and vmulss seems problematic here... Block RThroughput is better for ICC.
<a href="https://gcc.godbolt.org/z/rb1WMY">https://gcc.godbolt.org/z/rb1WMY</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>