This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix dbl-64 hypot spurious underflows (bug 16314)


This patch, relative to a tree with
<https://sourceware.org/ml/libc-alpha/2013-12/msg00597.html> applied,
fixes bug 16314, spurious underflows from dbl-64 hypot for input
values a bit above 0x1p-500.  In these cases, squaring the inputs does
not result in underflow, but squaring values constructed as low parts
of inputs does result in underflow; the fix is simply to adjust the
threshold for scaling up inputs from 0x1p-500 to 0x1p-450 (the same as
used for ldbl-128ibm).  I don't think any of the other hypot
implementations have this particular problem.

Tested x86_64 (32-bit x86 build is currently broken); no ulps updates
needed.

(auto-libm-test-out diffs omitted.)

2013-12-16  Joseph Myers  <joseph@codesourcery.com>

	[BZ #16314]
	* sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Adjust up
	values below 2**-450, not 2**-500.
	* math/auto-libm-test-in: Don't allow spurious underflow from
	hypot.
	* math/auto-libm-test-out: Regenerated.

diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index 980b6b9..dd4fd22 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -302,8 +302,7 @@ hypot -5.7e7 0
 hypot 0.75 1.25
 hypot 1.0 0x1p-61
 hypot 0x1p+0 0x1.fp-129
-# Bug 16314: spurious underflow exception may occur.
-hypot 0x1.23456789abcdef0123456789ab8p-500 0x1.23456789abcdef0123456789ab8p-500 spurious-underflow:dbl-64
+hypot 0x1.23456789abcdef0123456789ab8p-500 0x1.23456789abcdef0123456789ab8p-500
 hypot 0x3p125 0x4p125 no-test-inline:flt-32
 hypot 0x1.234566p-126 0x1.234566p-126 no-test-inline:flt-32
 hypot 0x3p1021 0x4p1021 no-test-inline:dbl-64
diff --git a/sysdeps/ieee754/dbl-64/e_hypot.c b/sysdeps/ieee754/dbl-64/e_hypot.c
index 500658d..88242bc 100644
--- a/sysdeps/ieee754/dbl-64/e_hypot.c
+++ b/sysdeps/ieee754/dbl-64/e_hypot.c
@@ -89,7 +89,7 @@ __ieee754_hypot (double x, double y)
       SET_HIGH_WORD (a, ha);
       SET_HIGH_WORD (b, hb);
     }
-  if (__builtin_expect (hb < 0x20b00000, 0))            /* b < 2**-500 */
+  if (__builtin_expect (hb < 0x23d00000, 0))            /* b < 2**-450 */
     {
       if (hb <= 0x000fffff)             /* subnormal b or 0 */
 	{

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]