<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 --- - calling double-precision sqrt with a float: not so fast, fast-math"
href="http://llvm.org/bugs/show_bug.cgi?id=17758">17758</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>calling double-precision sqrt with a float: not so fast, fast-math
</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>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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kkhoo@perfwizard.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>$ cat sqrt.c
#include <math.h>
float foo(float x) {
return sqrt(x);
}
Compiled for x86-64 *without* fast-math produces (extra text removed):
$ ./clang -O3 -fomit-frame-pointer -o - -S sqrt.c
_foo: ## @foo
sqrtss %xmm0, %xmm0
ret
Compiled for x86-64 *with* fast-math produces:
$ ./clang -O3 -fomit-frame-pointer -o - -S sqrt.c -ffast-math
_foo: ## @foo
cvtss2sd %xmm0, %xmm0
sqrtsd %xmm0, %xmm0
cvtsd2ss %xmm0, %xmm0
ret
I'm not sure if there are one or two bugs here:
1. Without fast-math, is it legal to *not* have the type conversions (ie, is
the compiler allowed to transform a call to double-precision 'sqrt' into
'sqrtf')?
2. With fast-math, I would expect to avoid the type conversions and use of the
double-precision square root instruction (ie, the compiler should convert the
call to 'sqrt' to 'sqrtf' because the input and output are both
single-precision).
This is with:
$ ./clang -v
clang version 3.4 (trunk 193529) (llvm/trunk 193527)
Target: x86_64-apple-darwin11.4.2
Thread model: posix</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>