Fix hypot handling of subnormals (bug 16316, bug 16330).

This commit is contained in:
Joseph Myers 2013-12-17 13:42:13 +00:00
parent e4a110f59e
commit c88769dda4
7 changed files with 1916 additions and 682 deletions

View File

@ -1,3 +1,19 @@
2013-12-17 Joseph Myers <joseph@codesourcery.com>
[BZ #16316]
[BZ #16330]
* sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Update
values of ha and hb and sort them after adjusting subnormal
arguments.
* sysdeps/ieee754/ldbl-128/e_hypotl.c (__ieee754_hypotl):
Likewise.
* sysdeps/ieee754/ldbl-96/e_hypotl.c (__ieee754_hypotl): Update
values of ea and eb and sort them after adjusting subnormal
arguments.
* math/auto-libm-test-in: Do not expect some hypot tests of
subnormals to fail. Add more hypot tests.
* math/auto-libm-test-out: Regenerated.
2013-12-16 Kaz Kojima <kkojima@rr.iij4u.or.jp>
[BZ #13304]

2
NEWS
View File

@ -22,7 +22,7 @@ Version 2.19
15988, 15997, 16032, 16034, 16036, 16037, 16038, 16041, 16055, 16071,
16072, 16074, 16077, 16078, 16103, 16112, 16143, 16144, 16146, 16150,
16151, 16153, 16167, 16172, 16195, 16214, 16245, 16271, 16274, 16283,
16289.
16289, 16316, 16330.
* The public headers no longer use __unused nor __block. This change is to
support compiling programs that are derived from BSD sources and use

View File

@ -282,6 +282,10 @@ expm1 100000.0
expm1 max
expm1 -max
hypot 0 0
hypot 0 -0
hypot -0 0
hypot -0 -0
# hypot (x,y) == hypot (+-x, +-y).
hypot 0.7 12.4
hypot -0.7 12.4
@ -307,9 +311,15 @@ hypot 0x1p+0 0x0.3ep-1022 no-test-inline:dbl-64
hypot 0x3p16381 0x4p16381 no-test-inline
hypot 0x1p-149 0x1p-149
hypot 0x1p-1074 0x1p-1074
# Bug 16316: hypot broken for some subnormal arguments.
hypot 0x1p-16445 0x1p-16445 no-test-inline xfail:ldbl-96-intel xfail:ldbl-96-m68k
hypot 0x1p-16494 0x1p-16494 no-test-inline xfail:ldbl-96-intel xfail:ldbl-96-m68k
hypot 0x1p-16445 0x1p-16445 no-test-inline
hypot 0x1p-16494 0x1p-16494 no-test-inline
hypot 0x0.fffffep-126 0x0.fp-127
hypot 0x0.fffffep-126 0x0.fp-130
hypot 0x0.fffffffffffffp-1022 0x0.fp-1023
hypot 0x0.fffffffffffffp-1022 0x0.fp-1026
hypot 0x0.ffffffp-16382 0x0.fp-16383
hypot 0x0.ffffffp-16382 0x0.fp-16386
hypot 0 min_subnorm
j0 -1.0
j0 0.0

File diff suppressed because it is too large Load Diff

View File

@ -102,6 +102,17 @@ __ieee754_hypot (double x, double y)
b *= t1;
a *= t1;
k -= 1022;
GET_HIGH_WORD (ha, a);
GET_HIGH_WORD (hb, b);
if (hb > ha)
{
t1 = a;
a = b;
b = t1;
j = ha;
ha = hb;
hb = j;
}
}
else /* scale a and b by 2^600 */
{

View File

@ -89,6 +89,17 @@ __ieee754_hypotl(long double x, long double y)
b *= t1;
a *= t1;
k -= 16382;
GET_LDOUBLE_MSW64 (ha, a);
GET_LDOUBLE_MSW64 (hb, b);
if (hb > ha)
{
t1 = a;
a = b;
b = t1;
j = ha;
ha = hb;
hb = j;
}
} else { /* scale a and b by 2^9600 */
ha += 0x2580000000000000LL; /* a *= 2^9600 */
hb += 0x2580000000000000LL; /* b *= 2^9600 */

View File

@ -89,6 +89,17 @@ long double __ieee754_hypotl(long double x, long double y)
b *= t1;
a *= t1;
k -= 16382;
GET_LDOUBLE_EXP (ea, a);
GET_LDOUBLE_EXP (eb, b);
if (eb > ea)
{
t1 = a;
a = b;
b = t1;
j = ea;
ea = eb;
eb = j;
}
} else { /* scale a and b by 2^9600 */
ea += 0x2580; /* a *= 2^9600 */
eb += 0x2580; /* b *= 2^9600 */