glibc/sysdeps
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
..
aarch64 [AArch64] Add optimized strchr. 2014-06-19 11:03:59 +01:00
alpha Alpha: Define TLS_DEFINE_INIT_TP 2014-06-11 12:23:35 -07:00
arm [BZ #17075] ARM: Fix immediate calculation of R_ARM_TLS_DESC 2014-06-20 20:22:42 +01:00
generic Add generic HAVE_RM_CTX implementation 2014-06-23 17:29:00 +01:00
gnu Silence a missing-noreturn warning for _Unwind_Resume. 2014-05-09 10:06:20 -07:00
hppa HPPA: Define TLS_DEFINE_INIT_TP 2014-06-09 14:04:45 -07:00
i386 Fix cosh spurious underflows from expm1 (bug 16354), inaccurate results near 0 (bug 17061). 2014-06-23 20:20:10 +00:00
ia64 [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
ieee754 Fix cosh spurious underflows from expm1 (bug 16354), inaccurate results near 0 (bug 17061). 2014-06-23 20:20:10 +00:00
init_array Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
m68k m68k: Consolidate nptl/ subdirectories under linux/... 2014-06-23 09:24:18 -07:00
mach Remove second argument from TLS_INIT_TP macro 2014-05-27 14:48:46 +02:00
microblaze Remove second argument from TLS_INIT_TP macro 2014-05-27 14:48:46 +02:00
mips MIPS: Move NPTL public headers to sysdeps/mips/nptl/. 2014-06-23 09:25:41 -07:00
nptl Add adaptive elision to rwlocks 2014-06-13 13:15:28 -07:00
posix Return EAI_AGAIN for AF_UNSPEC when herrno is TRY_AGAIN (BZ #16849) 2014-05-15 12:33:11 +05:30
powerpc PowerPC: sync hwcap.h capabilities 2014-06-23 09:40:05 -05:00
pthread Use list.h in posix-timer code. 2014-06-12 14:17:14 -07:00
s390 Use $(rtld-prefix) more consistently. 2014-06-18 10:35:29 +00:00
sh Include <kernel-features.h> explicitly where required. 2014-06-20 23:24:00 +00:00
sparc Missing new file from last commit. 2014-06-20 17:27:16 -07:00
tile Add adaptive elision to rwlocks 2014-06-13 13:15:28 -07:00
unix powerpc: Consolidate nptl/ subdirectories under linux/.... 2014-06-23 09:40:01 -07:00
wordsize-32 Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
wordsize-64 Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
x86 Fix pow overflow in non-default rounding modes (bug 16315). 2014-06-23 20:12:33 +00:00
x86_64 Test cpow in all rounding modes. 2014-06-23 20:15:14 +00:00