<html>
<head>
<base href="https://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 --- - [linux] clang should define _FP_FAST_FMA, _FP_FAST_FMAF, _FP_FAST_FMAL when fma(), fmaf(), fmal() is faster than an add and a mul"
href="https://llvm.org/bugs/show_bug.cgi?id=25728">25728</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[linux] clang should define _FP_FAST_FMA, _FP_FAST_FMAF, _FP_FAST_FMAL when fma(), fmaf(), fmal() is faster than an add and a mul
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Linux mathdef.h contains:
/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}
builtins are supported. */
# if __FP_FAST_FMA
# define FP_FAST_FMA 1
# endif
# if __FP_FAST_FMAF
# define FP_FAST_FMAF 1
# endif
# if __FP_FAST_FMAL
# define FP_FAST_FMAL 1
# endif
The comment isn't quite right; it looks like gcc will define these when the
builtin is replaced with an efficient intrinsic.
thakis@thakis:~/src/chrome/src$ cat test.c
#include <math.h>
#ifdef FP_FAST_FMAF
#warning on
#else
#warning off
#endif
thakis@thakis:~/src/chrome/src$ gcc -c test.c
test.c:6:2: warning: #warning off [-Wcpp]
#warning off
^
thakis@thakis:~/src/chrome/src$ gcc -c test.c -march=core-avx2
test.c:4:2: warning: #warning on [-Wcpp]
#warning on
^
With clang on the other hand it appears that this is never fast, even though
clang does generate vfmadd213sd just fine when calling fma():
thakis@thakis:~/src/chrome/src$
third_party/llvm-build/Release+Asserts/bin/clang -c test.c
test.c:6:2: warning: off [-W#warnings]
#warning off
^
1 warning generated.
thakis@thakis:~/src/chrome/src$
third_party/llvm-build/Release+Asserts/bin/clang -c test.c -march=core-avx2
test.c:6:2: warning: off [-W#warnings]
#warning off
^
1 warning generated.</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>