summaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/dbl-64
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2020-05-29 15:58:33 -0700
committerVineet Gupta <vgupta@synopsys.com>2020-06-03 10:23:28 -0700
commit628d90c5f97b6f0f8b79a079b682febb1f486a38 (patch)
treeb62fc668b7ba6f44cfdd8e74617f563929c80506 /sysdeps/ieee754/dbl-64
parent3374868668e708581ca06e256f6122518c89a8ad (diff)
downloadglibc-628d90c5f97b6f0f8b79a079b682febb1f486a38.tar
glibc-628d90c5f97b6f0f8b79a079b682febb1f486a38.tar.gz
glibc-628d90c5f97b6f0f8b79a079b682febb1f486a38.tar.bz2
glibc-628d90c5f97b6f0f8b79a079b682febb1f486a38.zip
ieee754: provide gcc builtins based generic fma functions
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/ieee754/dbl-64')
-rw-r--r--sysdeps/ieee754/dbl-64/s_fma.c6
-rw-r--r--sysdeps/ieee754/dbl-64/s_fmaf.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c
index 876df6e78b..9dc5b132b9 100644
--- a/sysdeps/ieee754/dbl-64/s_fma.c
+++ b/sysdeps/ieee754/dbl-64/s_fma.c
@@ -25,6 +25,7 @@
#include <fenv_private.h>
#include <libm-alias-double.h>
#include <tininess.h>
+#include <math-use-builtins.h>
/* This implementation uses rounding to odd to avoid problems with
double rounding. See a paper by Boldo and Melquiond:
@@ -33,6 +34,10 @@
double
__fma (double x, double y, double z)
{
+#if USE_FMA_BUILTIN
+ return __builtin_fma (x, y, z);
+#else
+ /* Use generic implementation. */
union ieee754_double u, v, w;
int adjust = 0;
u.d = x;
@@ -292,6 +297,7 @@ __fma (double x, double y, double z)
v.ieee.mantissa1 |= j;
return v.d * 0x1p-108;
}
+#endif /* ! USE_FMA_BUILTIN */
}
#ifndef __fma
libm_alias_double (__fma, fma)
diff --git a/sysdeps/ieee754/dbl-64/s_fmaf.c b/sysdeps/ieee754/dbl-64/s_fmaf.c
index 57329d0a87..93b8660d52 100644
--- a/sysdeps/ieee754/dbl-64/s_fmaf.c
+++ b/sysdeps/ieee754/dbl-64/s_fmaf.c
@@ -23,6 +23,7 @@
#include <math-barriers.h>
#include <fenv_private.h>
#include <libm-alias-float.h>
+#include <math-use-builtins.h>
/* This implementation relies on double being more than twice as
precise as float and uses rounding to odd in order to avoid problems
@@ -33,6 +34,10 @@
float
__fmaf (float x, float y, float z)
{
+#if USE_FMAF_BUILTIN
+ return __builtin_fmaf (x, y, z);
+#else
+ /* Use generic implementation. */
fenv_t env;
/* Multiplication is always exact. */
@@ -60,6 +65,7 @@ __fmaf (float x, float y, float z)
/* And finally truncation with round to nearest. */
return (float) u.d;
+#endif /* ! USE_FMAF_BUILTIN */
}
#ifndef __fmaf
libm_alias_float (__fma, fma)