]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgfortran: Provide some further math library fallbacks [PR94694]
authorJakub Jelinek <jakub@redhat.com>
Wed, 22 Apr 2020 17:17:15 +0000 (19:17 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 22 Apr 2020 19:34:19 +0000 (21:34 +0200)
The following patch provides some further math library fallbacks.
fmaf can be implemented using fma if available, fma and fmal can use
x * y + z as fallback, it is not perfect, but e.g. glibc on various arches
has been using that as fallback for many years,
and copysign/copysignl/fabs/fabsl can be implemented using corresponding
__builtin_* if we make sure that gcc expands it inline instead of using
a library call (these days it is expanded inline on most targets).

2020-04-22  Jakub Jelinek  <jakub@redhat.com>

PR libfortran/94694
PR libfortran/94586
* configure.ac: Add math func checks for fmaf, fma and fmal.  Add
HAVE_INLINE_BUILTIN_COPYSIGN check.
* c99_protos.h (copysign, fmaf, fma, fmal): Provide fallback
prototypes.
(HAVE_COPYSIGN, HAVE_FMAF, HAVE_FMA, HAVE_FMAL): Define if not
defined and fallback version is provided.
* intrinsics/c99_functions.c (copysign, fmaf, fma, fmal): Provide
fallback implementations if possible
* configure: Regenerated.
* config.h.in: Regenerated.

* math.m4 (GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1,
GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2): New.

config/ChangeLog
config/math.m4
libgfortran/ChangeLog
libgfortran/c99_protos.h
libgfortran/config.h.in
libgfortran/configure
libgfortran/configure.ac
libgfortran/intrinsics/c99_functions.c

index 01428dd04ee3be63b382277a8f04dfce1fe76c64..82b6d35ede7a4a2bb3fad115d3ad5f968733a275 100644 (file)
@@ -1,8 +1,14 @@
+2020-04-22  Jakub Jelinek  <jakub@redhat.com>
+
+       PR libfortran/94694
+       PR libfortran/94586
+       * math.m4 (GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1,
+       GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2): New.
+
 2020-02-12  Sandra Loosemore  <sandra@codesourcery.com>
 
        PR libstdc++/79193
        PR libstdc++/88999
-
        * no-executables.m4: Use a non-empty program to test for linker
        support.
 
index 155967e5071faa26ddcc94ad1f82599cd3c7d19b..e1e88d075edeec4ac7eb731878750596b14dc37c 100644 (file)
@@ -48,3 +48,67 @@ main ()
                        [Define to 1 if you have the `$1' function.])
   fi
 ])
+
+dnl GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1([name], [type])
+dnl
+dnl Check if math function NAME fallback for function with single
+dnl TYPE argument and TYPE result can be implemented using
+dnl __builtin_NAME expanded inline without needing unavailable math
+dnl library function.
+AC_DEFUN([GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1],
+[
+  AC_REQUIRE([GCC_CHECK_LIBM])
+if test $gcc_cv_math_func_$1 = no; then
+  AC_CACHE_CHECK([for inline __builtin_$1], [gcc_cv_math_inline_builtin_$1],
+                [AC_LINK_IFELSE([AC_LANG_SOURCE([
+$2
+$1_fallback ($2 x)
+{
+  return __builtin_$1 (x);
+}
+
+int
+main ()
+{
+  return 0;
+}
+])],
+[gcc_cv_math_inline_builtin_$1=yes],
+[gcc_cv_math_inline_builtin_$1=no])])
+  if test $gcc_cv_math_inline_builtin_$1 = yes; then
+    AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_INLINE_BUILTIN_$1),[1],
+             [Define to 1 if `__builtin_$1' is expanded inline.])
+  fi
+fi])
+
+dnl GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2([name], [type])
+dnl
+dnl Check if math function NAME fallback for function with two
+dnl TYPE arguments and TYPE result can be implemented using
+dnl __builtin_NAME expanded inline without needing unavailable math
+dnl library function.
+AC_DEFUN([GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2],
+[
+  AC_REQUIRE([GCC_CHECK_LIBM])
+if test $gcc_cv_math_func_$1 = no; then
+  AC_CACHE_CHECK([for inline __builtin_$1], [gcc_cv_math_inline_builtin_$1],
+                [AC_LINK_IFELSE([AC_LANG_SOURCE([
+$2
+$1_fallback ($2 x, $2 y)
+{
+  return __builtin_$1 (x, y);
+}
+
+int
+main ()
+{
+  return 0;
+}
+])],
+[gcc_cv_math_inline_builtin_$1=yes],
+[gcc_cv_math_inline_builtin_$1=no])])
+  if test $gcc_cv_math_inline_builtin_$1 = yes; then
+    AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_INLINE_BUILTIN_$1),[1],
+             [Define to 1 if `__builtin_$1' is expanded inline.])
+  fi
+fi])
index 2ca75f190bc9016e5428e4f55c08de547a3cc4e1..e4d3756f0cab41e2a45f7f8eda116a110bde896d 100644 (file)
@@ -1,3 +1,18 @@
+2020-04-22  Jakub Jelinek  <jakub@redhat.com>
+
+       PR libfortran/94694
+       PR libfortran/94586
+       * configure.ac: Add math func checks for fmaf, fma and fmal.  Add
+       HAVE_INLINE_BUILTIN_COPYSIGN check.
+       * c99_protos.h (copysign, fmaf, fma, fmal): Provide fallback
+       prototypes.
+       (HAVE_COPYSIGN, HAVE_FMAF, HAVE_FMA, HAVE_FMAL): Define if not
+       defined and fallback version is provided.
+       * intrinsics/c99_functions.c (copysign, fmaf, fma, fmal): Provide
+       fallback implementations if possible
+       * configure: Regenerated.
+       * config.h.in: Regenerated.
+
 2020-04-19  Uroš Bizjak  <ubizjak@gmail.com>
 
        * config/fpu-387.h (local_feraiseexcept) [__SSE_MATH__]:
index 7b0bc720de392e2ccb8603492766e1e58e9dbdde..1ffc645cfeb6dfd305dd1051b6dc660ed8ce4b6c 100644 (file)
@@ -71,6 +71,16 @@ extern float ceilf(float);
 extern float copysignf(float, float);
 #endif
 
+#if !defined(HAVE_COPYSIGN) && defined(HAVE_INLINE_BUILTIN_COPYSIGN)
+#define HAVE_COPYSIGN 1
+extern double copysign(double, double);
+#endif
+
+#if !defined(HAVE_COPYSIGNL) && defined(HAVE_INLINE_BUILTIN_COPYSIGNL)
+#define HAVE_COPYSIGNL 1
+extern long double copysignl(long double, long double);
+#endif
+
 #ifndef HAVE_COSF
 #define HAVE_COSF 1
 extern float cosf(float);
@@ -91,6 +101,16 @@ extern float expf(float);
 extern float fabsf(float);
 #endif
 
+#if !defined(HAVE_FABS) && defined(HAVE_INLINE_BUILTIN_FABS)
+#define HAVE_FABS 1
+extern double fabs(double);
+#endif
+
+#if !defined(HAVE_FABSL) && defined(HAVE_INLINE_BUILTIN_FABSL)
+#define HAVE_FABSL 1
+extern long double fabsl(long double);
+#endif
+
 #ifndef HAVE_FLOORF
 #define HAVE_FLOORF 1
 extern float floorf(float);
@@ -628,6 +648,20 @@ extern float tgammaf (float);
 extern float lgammaf (float);
 #endif
 
+#ifndef HAVE_FMA
+#define HAVE_FMA 1
+extern double fma(double, double, double);
+#endif
+
+#ifndef HAVE_FMAF
+#define HAVE_FMAF 1
+extern float fmaf(float, float, float);
+#endif
+
+#ifndef HAVE_FMAL
+#define HAVE_FMAL 1
+extern long double fmal(long double, long double, long double);
+#endif
 
 #endif  /* C99_PROTOS_H  */
 
index 4478639998771b3d19756e5d185c136b320ede19..2d58188e50ce1fbf38167d13d3202ea143f96c9c 100644 (file)
 /* Define to 1 if you have the `floorl' function. */
 #undef HAVE_FLOORL
 
+/* Define to 1 if you have the `fma' function. */
+#undef HAVE_FMA
+
 /* Define if FMA3 instructions can be compiled. */
 #undef HAVE_FMA3
 
 /* Define if FMA4 instructions can be compiled. */
 #undef HAVE_FMA4
 
+/* Define to 1 if you have the `fmaf' function. */
+#undef HAVE_FMAF
+
+/* Define to 1 if you have the `fmal' function. */
+#undef HAVE_FMAL
+
 /* Define to 1 if you have the `fmod' function. */
 #undef HAVE_FMOD
 
 /* Define to 1 if you have the <ieeefp.h> header file. */
 #undef HAVE_IEEEFP_H
 
+/* Define to 1 if `__builtin_copysign' is expanded inline. */
+#undef HAVE_INLINE_BUILTIN_COPYSIGN
+
+/* Define to 1 if `__builtin_copysignl' is expanded inline. */
+#undef HAVE_INLINE_BUILTIN_COPYSIGNL
+
+/* Define to 1 if `__builtin_fabs' is expanded inline. */
+#undef HAVE_INLINE_BUILTIN_FABS
+
+/* Define to 1 if `__builtin_fabsl' is expanded inline. */
+#undef HAVE_INLINE_BUILTIN_FABSL
+
 /* Define to 1 if the system has the type `intptr_t'. */
 #undef HAVE_INTPTR_T
 
index d01654e7c4b7f94047f673a7473dd8947f7e1eb2..b4cf854ddb399ae206b96a5f0924f19d935ad7c4 100755 (executable)
@@ -19848,6 +19848,150 @@ _ACEOF
 
 
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fmaf" >&5
+$as_echo_n "checking for fmaf... " >&6; }
+if ${gcc_cv_math_func_fmaf+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef HAVE_COMPLEX_H
+#include <complex.h>
+#endif
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+
+int (*ptr)() = (int (*)())fmaf;
+
+int
+main ()
+{
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_math_func_fmaf=yes
+else
+  gcc_cv_math_func_fmaf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_math_func_fmaf" >&5
+$as_echo "$gcc_cv_math_func_fmaf" >&6; }
+  if test $gcc_cv_math_func_fmaf = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_FMAF 1
+_ACEOF
+
+  fi
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fma" >&5
+$as_echo_n "checking for fma... " >&6; }
+if ${gcc_cv_math_func_fma+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef HAVE_COMPLEX_H
+#include <complex.h>
+#endif
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+
+int (*ptr)() = (int (*)())fma;
+
+int
+main ()
+{
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_math_func_fma=yes
+else
+  gcc_cv_math_func_fma=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_math_func_fma" >&5
+$as_echo "$gcc_cv_math_func_fma" >&6; }
+  if test $gcc_cv_math_func_fma = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_FMA 1
+_ACEOF
+
+  fi
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fmal" >&5
+$as_echo_n "checking for fmal... " >&6; }
+if ${gcc_cv_math_func_fmal+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef HAVE_COMPLEX_H
+#include <complex.h>
+#endif
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+
+int (*ptr)() = (int (*)())fmal;
+
+int
+main ()
+{
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_math_func_fmal=yes
+else
+  gcc_cv_math_func_fmal=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_math_func_fmal" >&5
+$as_echo "$gcc_cv_math_func_fmal" >&6; }
+  if test $gcc_cv_math_func_fmal = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_FMAL 1
+_ACEOF
+
+  fi
+
+
+
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fmodf" >&5
 $as_echo_n "checking for fmodf... " >&6; }
 if ${gcc_cv_math_func_fmodf+:} false; then :
@@ -25559,6 +25703,187 @@ $as_echo "#define HAVE_CLOG 1" >>confdefs.h
 fi
 
 
+
+
+if test $gcc_cv_math_func_copysign = no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline __builtin_copysign" >&5
+$as_echo_n "checking for inline __builtin_copysign... " >&6; }
+if ${gcc_cv_math_inline_builtin_copysign+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+double
+copysign_fallback (double x, double y)
+{
+  return __builtin_copysign (x, y);
+}
+
+int
+main ()
+{
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_math_inline_builtin_copysign=yes
+else
+  gcc_cv_math_inline_builtin_copysign=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_math_inline_builtin_copysign" >&5
+$as_echo "$gcc_cv_math_inline_builtin_copysign" >&6; }
+  if test $gcc_cv_math_inline_builtin_copysign = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INLINE_BUILTIN_COPYSIGN 1
+_ACEOF
+
+  fi
+fi
+
+
+if test $gcc_cv_math_func_copysignl = no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline __builtin_copysignl" >&5
+$as_echo_n "checking for inline __builtin_copysignl... " >&6; }
+if ${gcc_cv_math_inline_builtin_copysignl+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+long double
+copysignl_fallback (long double x, long double y)
+{
+  return __builtin_copysignl (x, y);
+}
+
+int
+main ()
+{
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_math_inline_builtin_copysignl=yes
+else
+  gcc_cv_math_inline_builtin_copysignl=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_math_inline_builtin_copysignl" >&5
+$as_echo "$gcc_cv_math_inline_builtin_copysignl" >&6; }
+  if test $gcc_cv_math_inline_builtin_copysignl = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INLINE_BUILTIN_COPYSIGNL 1
+_ACEOF
+
+  fi
+fi
+
+
+if test $gcc_cv_math_func_fabs = no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline __builtin_fabs" >&5
+$as_echo_n "checking for inline __builtin_fabs... " >&6; }
+if ${gcc_cv_math_inline_builtin_fabs+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+double
+fabs_fallback (double x)
+{
+  return __builtin_fabs (x);
+}
+
+int
+main ()
+{
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_math_inline_builtin_fabs=yes
+else
+  gcc_cv_math_inline_builtin_fabs=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_math_inline_builtin_fabs" >&5
+$as_echo "$gcc_cv_math_inline_builtin_fabs" >&6; }
+  if test $gcc_cv_math_inline_builtin_fabs = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INLINE_BUILTIN_FABS 1
+_ACEOF
+
+  fi
+fi
+
+
+if test $gcc_cv_math_func_fabsl = no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline __builtin_fabsl" >&5
+$as_echo_n "checking for inline __builtin_fabsl... " >&6; }
+if ${gcc_cv_math_inline_builtin_fabsl+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+long double
+fabsl_fallback (long double x)
+{
+  return __builtin_fabsl (x);
+}
+
+int
+main ()
+{
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gcc_cv_math_inline_builtin_fabsl=yes
+else
+  gcc_cv_math_inline_builtin_fabsl=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_math_inline_builtin_fabsl" >&5
+$as_echo "$gcc_cv_math_inline_builtin_fabsl" >&6; }
+  if test $gcc_cv_math_inline_builtin_fabsl = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INLINE_BUILTIN_FABSL 1
+_ACEOF
+
+  fi
+fi
+
 # Check whether the system has a working stat()
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the target stat is reliable" >&5
index b2b9ee994aa7ab5b69c8fcb7eb4ab118069b87bf..711dc60ff78e97c13b3b86db69e2aa2b2d290b76 100644 (file)
@@ -392,6 +392,9 @@ GCC_CHECK_MATH_FUNC([cabsl])
 GCC_CHECK_MATH_FUNC([floorf])
 GCC_CHECK_MATH_FUNC([floor])
 GCC_CHECK_MATH_FUNC([floorl])
+GCC_CHECK_MATH_FUNC([fmaf])
+GCC_CHECK_MATH_FUNC([fma])
+GCC_CHECK_MATH_FUNC([fmal])
 GCC_CHECK_MATH_FUNC([fmodf])
 GCC_CHECK_MATH_FUNC([fmod])
 GCC_CHECK_MATH_FUNC([fmodl])
@@ -516,6 +519,11 @@ GCC_CHECK_MATH_FUNC([catanl])
 # On AIX, clog is present in libm as __clog
 AC_CHECK_LIB([m],[__clog],[AC_DEFINE([HAVE_CLOG],[1],[libm includes clog])])
 
+GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2([copysign], [double])
+GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2([copysignl], [long double])
+GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1([fabs], [double])
+GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1([fabsl], [long double])
+
 # Check whether the system has a working stat()
 LIBGFOR_CHECK_WORKING_STAT
 
index 3ec5aeb8e0536ec2618b65f0a5287637ce4b0f7d..b75d1777c4c098e84665d6f1793ff3710872f76b 100644 (file)
@@ -229,6 +229,17 @@ ceilf (float x)
 }
 #endif
 
+#if !defined(HAVE_COPYSIGN) && defined(HAVE_INLINE_BUILTIN_COPYSIGN)
+#define HAVE_COPYSIGN 1
+double copysign (double x, double y);
+
+double
+copysign (double x, double y)
+{
+  return __builtin_copysign (x, y);
+}
+#endif
+
 #ifndef HAVE_COPYSIGNF
 #define HAVE_COPYSIGNF 1
 float copysignf (float x, float y);
@@ -240,6 +251,17 @@ copysignf (float x, float y)
 }
 #endif
 
+#if !defined(HAVE_COPYSIGNL) && defined(HAVE_INLINE_BUILTIN_COPYSIGNL)
+#define HAVE_COPYSIGNL 1
+long double copysignl (long double x, long double y);
+
+long double
+copysignl (long double x, long double y)
+{
+  return __builtin_copysignl (x, y);
+}
+#endif
+
 #ifndef HAVE_COSF
 #define HAVE_COSF 1
 float cosf (float x);
@@ -273,6 +295,17 @@ expf (float x)
 }
 #endif
 
+#if !defined(HAVE_FABS) && defined(HAVE_INLINE_BUILTIN_FABS)
+#define HAVE_FABS 1
+double fabs (double x);
+
+double
+fabs (double x)
+{
+  return __builtin_fabs (x);
+}
+#endif
+
 #ifndef HAVE_FABSF
 #define HAVE_FABSF 1
 float fabsf (float x);
@@ -284,6 +317,17 @@ fabsf (float x)
 }
 #endif
 
+#if !defined(HAVE_FABSL) && defined(HAVE_INLINE_BUILTIN_FABSL)
+#define HAVE_FABSL 1
+long double fabsl (long double x);
+
+long double
+fabsl (long double x)
+{
+  return __builtin_fabsl (x);
+}
+#endif
+
 #ifndef HAVE_FLOORF
 #define HAVE_FLOORF 1
 float floorf (float x);
@@ -2112,3 +2156,36 @@ lgammaf (float x)
   return (float) lgamma ((double) x);
 }
 #endif
+
+#ifndef HAVE_FMA
+#define HAVE_FMA 1
+double fma (double, double, double);
+
+double
+fma (double x, double y, double z)
+{
+  return x * y + z;
+}
+#endif
+
+#ifndef HAVE_FMAF
+#define HAVE_FMAF 1
+float fmaf (float, float, float);
+
+float
+fmaf (float x, float y, float z)
+{
+  return fma (x, y, z);
+}
+#endif
+
+#ifndef HAVE_FMAL
+#define HAVE_FMAL 1
+long double fmal (long double, long double, long double);
+
+long double
+fmal (long double x, long double y, long double z)
+{
+  return x * y + z;
+}
+#endif