public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] IEEE quad fmal fixes
@ 2010-10-18 10:17 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2010-10-18 10:17 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

I've used wrong value for denorm minimum and gcc on s390x scheduled
the TFmode addition after the fetestexcept call.
This patch fixes it both and adds some tests, with this
(and fixed mpfr_set_ld) the tester passed 10billion tests even
on s390x.

OT, there 28 failures out of 10billion tests in x86_64 fmal testing,
but at least the first one turned out to be a mpfr_sub1 bug:
https://gforge.inria.fr/tracker/index.php?func=detail&aid=11301&group_id=136&atid=619
so I'm waiting for that bug to be fixed now.  If all those 28 failures
are the same bug, then glibc fma{f,,l} should be fine now.

2010-10-16  Jakub Jelinek  <jakub@redhat.com>

	[BZ #3268]
	* math/libm-test.inc (fma_test): Add IEEE quad long double fmal
	tests.
	* sysdeps/ieee754/ldbl-128/s_fmal.c (__fmal): Ensure a1 + u.d
	computation is not scheduled after fetestexcept.  Fix value
	of minimum denormal long double.

--- libc/math/libm-test.inc.jj	2010-10-15 17:51:16.000000000 +0200
+++ libc/math/libm-test.inc	2010-10-16 17:35:05.000000000 +0200
@@ -2844,6 +2844,21 @@ fma_test (void)
   TEST_fff_f (fma, 0xc.0000000000007ffp+10130L, -0x8.000000000000001p+4430L, 0xc.07000000001ffffp+14513L, -0xb.fffffffffffd7e4p+14563L);
   TEST_fff_f (fma, 0xb.ffffp-4777L, 0x8.000000fffffffffp-11612L, -0x0.3800fff8p-16385L, 0x5.c7fe80c7ffeffffp-16385L);
 #endif
+#if defined (TEST_LDOUBLE) && LDBL_MANT_DIG == 113
+  TEST_fff_f (fma, 0x1.bb2de33e02ccbbfa6e245a7c1f71p-2584L, -0x1.6b500daf0580d987f1bc0cadfcddp-13777L, 0x1.613cd91d9fed34b33820e5ab9d8dp-16378L, -0x1.3a79fb50eb9ce887cffa0f09bd9fp-16360L);
+  TEST_fff_f (fma, -0x1.f949b880cacb0f0c61540105321dp-5954L, -0x1.3876cec84b4140f3bd6198731b7ep-10525L, -0x0.a5dc1c6cfbc498c54fb0b504bf19p-16382L, -0x0.a5dc1c6cfbc498c54fb0b5038abbp-16382L);
+  TEST_fff_f (fma, -0x1.0000fffffffffp-16221L, 0x1.0000001fffff8007fep-239L, 0x0.ff87ffffffffffffe000003fffffp-16382L, 0x0.ff87ffffffffffffdffc003bff7fp-16382L);
+  TEST_fff_f (fma, -0x1.ac79c9376ef447f3827c9e9de008p-2228L, -0x1.5ba830022b6139e21fbe7270cad8p-6314L, 0x1.e8282b6a26bb6a9daf5c8e73e9f9p-8616L, 0x1.22f14a0253878a730cd1aee373adp-8541L);
+  TEST_fff_f (fma, -0x1.c69749ec574caaa2ab8e97ddb9f3p+2652L, 0x1.f34235ff9d095449c29b4831b62dp+3311L, 0x1.fbe4302df23354dbd0c4d3cfe606p+5879L, -0x1.bb473bfdfb7a6e18886ce6e57eafp+5964L);
+  TEST_fff_f (fma, -0x1.ca8835fc6ecfb5398625fc891be5p-1686L, 0x1.621e1972bbe2180e5be9dd7d8df5p-7671L, -0x1.7d2d21b73b52cf20dec2a83902a4p-9395L, -0x1.3d2322191c9c88bc68a62ab8042cp-9356L);
+  TEST_fff_f (fma, -0x1.55cff679ec49c2541fab41fc843ep-11819L, 0x1.e60e9f464f9e8df0509647c7c971p+12325L, 0x1.eaa2a7649d765c2f564f7a5beca7p+454L, -0x1.447e29fa7e406a285f4e350fcf86p+507L);
+  TEST_fff_f (fma, 0x1.f0e7b1454908576f2537d863cf9bp+11432L, 0x1.cdce52f09d4ca76e68706f34b5d5p-1417L, -0x1.2e986187c70f146235ea2066e486p+9979L, 0x1.c030dad3cc5643f3dd0f5619f661p+10016L);
+  TEST_fff_f (fma, 0x1.f102f7da4a57a3a4aab620e29452p-3098L, -0x1.cc06a4ff40248f9e2dcc4b6afd84p-11727L, 0x1.d512a11126b5ac8ed8973b8580c8p-14849L, -0x1.be8f1cf737ab4d1c31c54f5ec23bp-14824L);
+  TEST_fff_f (fma, -0x1.fc47ac7434b993cd8dcb2b431f25p-3816L, 0x1.fbc9750da8468852d84558e1db6dp-5773L, -0x1.00a98abf783f75c40fe5b7a37d86p-9607L, -0x1.f81917b166f45e763cfcc057e2adp-9588L);
+  TEST_fff_f (fma, 0x1.00000000000007ffffffffffffffp-9045L, -0x1.ffffffffffff80000001ffffffffp+4773L, -0x1.f8p-4316L, -0x1.00000000000f88000000fffffdffp-4271L);
+  TEST_fff_f (fma, 0x1.4e922764c90701d4a2f21d01893dp-8683L, -0x1.955a12e2d7c9447c27fa022fc865p+212L, -0x1.e9634462eaef96528b90b6944578p-8521L, -0x1.08e1783184a371943d3598e10865p-8470L);
+  TEST_fff_f (fma, 0x1.801181509c03bdbef10d6165588cp-15131L, 0x1.ad86f8e57d3d40bfa8007780af63p-368L, -0x1.6e9df0dab1c9f1d7a6043c390741p-15507L, 0x1.417c9b2b15e2ad57dc9e0e920844p-15498L);
+#endif
 
   END (fma);
 }
--- libc/sysdeps/ieee754/ldbl-128/s_fmal.c.jj	2010-10-15 18:08:43.000000000 +0200
+++ libc/sysdeps/ieee754/ldbl-128/s_fmal.c	2010-10-16 17:17:15.000000000 +0200
@@ -175,6 +175,8 @@ __fmal (long double x, long double y, lo
       if ((u.ieee.mantissa3 & 1) == 0)
 	u.ieee.mantissa3 |= fetestexcept (FE_INEXACT) != 0;
       v.d = a1 + u.d;
+      /* Ensure the addition is not scheduled after fetestexcept call.  */
+      asm volatile ("" : "m" (v));
       int j = fetestexcept (FE_INEXACT) != 0;
       feupdateenv (&env);
       /* Ensure the following computations are performed in default rounding
@@ -207,9 +209,9 @@ __fmal (long double x, long double y, lo
 	    {
 	      v.d *= 0x1p-226L;
 	      if (v.ieee.negative)
-		return v.d - 0x1p-16493L /* __LDBL_DENORM_MIN__ */;
+		return v.d - 0x1p-16494L /* __LDBL_DENORM_MIN__ */;
 	      else
-		return v.d + 0x1p-16493L /* __LDBL_DENORM_MIN__ */;
+		return v.d + 0x1p-16494L /* __LDBL_DENORM_MIN__ */;
 	    }
 	  else
 	    return v.d * 0x1p-226L;

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-10-18 10:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-18 10:17 [PATCH] IEEE quad fmal fixes Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).