about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64/s_fma.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-10-15 15:26:06 -0400
committerUlrich Drepper <drepper@gmail.com>2010-10-15 15:26:06 -0400
commit3e692e0518b4f4679352d25102bd47cf3f85c592 (patch)
treea3f4cefdf037d6c72a8267277dbe0bd0922f2d3e /sysdeps/ieee754/dbl-64/s_fma.c
parentf3f7372de1401b99f0a318ce09caf73e42d6f022 (diff)
downloadglibc-3e692e0518b4f4679352d25102bd47cf3f85c592.tar.gz
glibc-3e692e0518b4f4679352d25102bd47cf3f85c592.tar.xz
glibc-3e692e0518b4f4679352d25102bd47cf3f85c592.zip
Implement fmal, some fma bugfixes
Diffstat (limited to 'sysdeps/ieee754/dbl-64/s_fma.c')
-rw-r--r--sysdeps/ieee754/dbl-64/s_fma.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c
index 911682eceb..3b0bfd5ce6 100644
--- a/sysdeps/ieee754/dbl-64/s_fma.c
+++ b/sysdeps/ieee754/dbl-64/s_fma.c
@@ -43,6 +43,12 @@ __fma (double x, double y, double z)
       || __builtin_expect (u.ieee.exponent + v.ieee.exponent
 			   <= IEEE754_DOUBLE_BIAS + DBL_MANT_DIG, 0))
     {
+      /* If z is Inf, but x and y are finite, the result should be
+	 z rather than NaN.  */
+      if (w.ieee.exponent == 0x7ff
+	  && u.ieee.exponent != 0x7ff
+          && v.ieee.exponent != 0x7ff)
+	return (z + x) + y;
       /* If x or y or z is Inf/NaN, or if fma will certainly overflow,
 	 or if x * y is less than half of DBL_DENORM_MIN,
 	 compute as x * y + z.  */
@@ -165,6 +171,8 @@ __fma (double x, double y, double z)
     }
   else
     {
+      if ((u.ieee.mantissa1 & 1) == 0)
+	u.ieee.mantissa1 |= fetestexcept (FE_INEXACT) != 0;
       v.d = a1 + u.d;
       int j = fetestexcept (FE_INEXACT) != 0;
       feupdateenv (&env);