From 628d90c5f97b6f0f8b79a079b682febb1f486a38 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 29 May 2020 15:58:33 -0700 Subject: ieee754: provide gcc builtins based generic fma functions Reviewed-by: Adhemerval Zanella --- sysdeps/ieee754/ldbl-128/s_fma.c | 5 +++++ sysdeps/ieee754/ldbl-128/s_fmal.c | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'sysdeps/ieee754/ldbl-128') diff --git a/sysdeps/ieee754/ldbl-128/s_fma.c b/sysdeps/ieee754/ldbl-128/s_fma.c index 13f8ed3b87..0feff0a71c 100644 --- a/sysdeps/ieee754/ldbl-128/s_fma.c +++ b/sysdeps/ieee754/ldbl-128/s_fma.c @@ -21,6 +21,7 @@ #include #include #include +#include /* This implementation relies on long double being more than twice as precise as double and uses rounding to odd in order to avoid problems @@ -31,6 +32,9 @@ double __fma (double x, double y, double z) { +#if USE_FMA_BUILTIN + return __builtin_fma (x, y, z); +#else fenv_t env; /* Multiplication is always exact. */ long double temp = (long double) x * (long double) y; @@ -50,6 +54,7 @@ __fma (double x, double y, double z) feupdateenv (&env); /* And finally truncation with round to nearest. */ return (double) u.d; +#endif /* ! USE_FMA_BUILTIN */ } #ifndef __fma libm_alias_double (__fma, fma) diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c b/sysdeps/ieee754/ldbl-128/s_fmal.c index 7475015bce..a610499e47 100644 --- a/sysdeps/ieee754/ldbl-128/s_fmal.c +++ b/sysdeps/ieee754/ldbl-128/s_fmal.c @@ -25,6 +25,7 @@ #include #include #include +#include /* This implementation uses rounding to odd to avoid problems with double rounding. See a paper by Boldo and Melquiond: @@ -33,6 +34,9 @@ _Float128 __fmal (_Float128 x, _Float128 y, _Float128 z) { +#if USE_FMAL_BUILTIN + return __builtin_fmal (x, y, z); +#else union ieee854_long_double u, v, w; int adjust = 0; u.d = x; @@ -296,5 +300,6 @@ __fmal (_Float128 x, _Float128 y, _Float128 z) v.ieee.mantissa3 |= j; return v.d * L(0x1p-228); } +#endif /* ! USE_FMAL_BUILTIN */ } libm_alias_ldouble (__fma, fma) -- cgit 1.4.1