<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - optimize reciprocal square root with fast-math (x86)"
href="http://llvm.org/bugs/show_bug.cgi?id=20900">20900</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>optimize reciprocal square root with fast-math (x86)
</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>normal
</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>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>$ ./clang -v
clang version 3.6.0 (217530)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
$ cat rsqrt.c
#include <math.h>
float reciprocal_square_root(float x) {
return 1.0f / sqrtf(x);
}
$ ./clang -O2 -ffast-math -S -o - rsqrt.c
...
sqrtss %xmm0, %xmm1
movss LCPI0_0(%rip), %xmm0
divss %xmm1, %xmm0
---------------------------------------------------------------------
This should be optimized to use 'rsqrtss'.
ICC 14 does this at -O2:
rsqrtss %xmm0, %xmm2
mulss %xmm2, %xmm0
mulss %xmm2, %xmm0
movss L_2il0floatpacket.2(%rip), %xmm1
mulss %xmm1, %xmm2
subss L_2il0floatpacket.1(%rip), %xmm0
mulss %xmm2, %xmm0
ret
L_2il0floatpacket.1:
.long 0x40400000
L_2il0floatpacket.2:
.long 0xbf000000</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>