https://llvm.org/bugs/show_bug.cgi?id=25728

            Bug ID: 25728
           Summary: [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
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: nicolaswe...@gmx.de
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to