glibc/sysdeps/ieee754/dbl-64
Joseph Myers 4648909d56 Fix cosh spurious underflows from expm1 (bug 16354), inaccurate results near 0 (bug 17061).
This patch fixes bug 16354, spurious underflows from cosh when a tiny
argument is passed to expm1 and expm1 correctly underflows although
the final result of cosh should be 1.  As noted in that bug, some
cases are latent because of expm1 implementations not raising
underflow (bug 16353), but all the implementations are fixed
similarly.  They already contained checks for tiny arguments, but the
checks were too late to avoid underflow from expm1 (although they
would avoid underflow from subsequent squaring of the result of
expm1); they are moved before the expm1 calls.

The thresholds used for considering arguments tiny are not
particularly consistent in how they relate to the precision of the
floating-point format in question.  They are, however, all sufficient
to ensure that the round-to-nearest result of cosh is indeed 1 below
the threshold (although sometimes they are smaller than necessary).
But the previous logic did not return 1, but the previously computed 1
+ expm1(abs(x)) value.  And the thresholds in the ldbl-128 and
ldbl-128ibm code (0x1p-71L - I suspect 0x3f8b was intended in the code
instead of 0x3fb8 - and (roughly) 0x1p-55L) are not sufficient for
that value to be 1.  So by moving the test for tiny arguments, and
consequently returning 1 directly now the expm1 value hasn't been
computed by that point, this patch also fixes bug 17061, the (large
number of ulps) inaccuracy for small arguments in those
implementations.  Tests for that bug are duly added.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 and powerpc32 to validate the ldbl-128 and ldbl-128ibm changes.

	[BZ #16354]
	[BZ #17061]
	* sysdeps/ieee754/dbl-64/e_cosh.c (__ieee754_cosh): Check for
	small arguments before calling __expm1.
	* sysdeps/ieee754/flt-32/e_coshf.c (__ieee754_coshf): Check for
	small arguments before calling __expm1f.
	* sysdeps/ieee754/ldbl-128/e_coshl.c (__ieee754_coshl): Check for
	small arguments before calling __expm1l.
	* sysdeps/ieee754/ldbl-128ibm/e_coshl.c (__ieee754_coshl):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_coshl.c (__ieee754_coshl): Likewise.
	* math/auto-libm-test-in: Add more cosh tests.  Do not allow
	spurious underflow for some cosh tests.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2014-06-23 20:20:10 +00:00
..
wordsize-64 [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
Makefile Compile e_sqrt.c with -ffp-contract=off. 2013-12-18 12:07:06 +00:00
MathLib.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
asincos.tbl Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
atnat.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
atnat2.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
branred.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
branred.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
dbl2mpn.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
dla.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
doasin.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
doasin.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
dosincos.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
dosincos.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
e_acos.c
e_acosh.c Format floating routines. 2013-10-17 16:03:24 +02:00
e_asin.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
e_atan2.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
e_atanh.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_cosh.c Fix cosh spurious underflows from expm1 (bug 16354), inaccurate results near 0 (bug 17061). 2014-06-23 20:20:10 +00:00
e_exp.c Fix implicit __isinf declarations in exp. 2014-03-24 22:00:32 +00:00
e_exp2.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_exp10.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
e_fmod.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_gamma_r.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_hypot.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_ilogb.c Format floating routines. 2013-10-17 16:03:24 +02:00
e_j0.c Format floating routines. 2013-10-17 16:03:24 +02:00
e_j1.c Set errno for y1 overflow (bug 17050). 2014-06-23 20:17:13 +00:00
e_jn.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_lgamma_r.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_log.c Fix log (1) in round-downward mode (bug 16731). 2014-03-21 18:13:58 +00:00
e_log2.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_log10.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_pow.c Fix pow overflow in non-default rounding modes (bug 16315). 2014-06-23 20:12:33 +00:00
e_rem_pio2.c Format floating routines. 2013-10-17 16:03:24 +02:00
e_remainder.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
e_sinh.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_sqrt.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
gamma_product.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
gamma_productf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
halfulp.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
k_cos.c
k_rem_pio2.c Format floating routines. 2013-10-17 16:03:24 +02:00
k_sin.c
k_tan.c Replace sysdeps/ieee754/dbl-64/k_tan.c with empty file 2012-02-26 16:10:46 +01:00
mpa-arch.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mpa.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mpa.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mpatan.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mpatan.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mpatan2.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mpexp.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mplog.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mpn2dbl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mpsqrt.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mpsqrt.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mptan.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
mydefs.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
powtwo.tbl Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
root.tbl Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_asinh.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_atan.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_cbrt.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_ceil.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_copysign.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_cos.c
s_erf.c Fix erf underflow handling near 0 (bug 16516). 2014-05-14 12:34:03 +00:00
s_expm1.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_fabs.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_finite.c PowerPC: multiarch finite/finitef for PowerPC32 2013-12-06 05:47:03 -06:00
s_floor.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_fma.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_fmaf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_fpclassify.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_frexp.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_isinf.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_isinf_ns.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_isnan.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_issignaling.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_llrint.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_llround.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_log1p.c [BZ #16823] Fix log1pl returning wrong infinity sign 2014-04-29 15:43:36 +02:00
s_logb.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_lrint.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_lround.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_modf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_nearbyint.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_nexttoward.c
s_remquo.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_rint.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_round.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_scalbln.c [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
s_scalbn.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_signbit.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_sin.c Fix sign of input to bsloww1 (BZ #16623) 2014-02-27 21:12:09 +05:30
s_sincos.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_tan.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_tanh.c Format floating routines. 2013-10-17 16:03:24 +02:00
s_trunc.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
sincos32.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
sincos32.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
sincostab.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
slowexp.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
slowpow.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
t_exp.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
t_exp2.h
uasncs.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
uatan.tbl Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
uexp.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
uexp.tbl Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
ulog.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
ulog.tbl Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
upow.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
upow.tbl Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
urem.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
uroot.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
usncs.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
utan.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
utan.tbl Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
w_exp.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
x2y2m1.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
x2y2m1f.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00