glibc/sysdeps
Joseph Myers 0bf061d3e3 Fix erf underflow handling near 0 (bug 16516).
Bug 16516 reports spurious underflows from erf (for all floating-point
types), when the result is close to underflowing but does not actually
underflow.

erf (x) is about (2/sqrt(pi))*x for x close to 0, so there are
subnormal arguments for which it does not underflow.  The various
implementations do (x + efx*x) (for efx = 2/sqrt(pi) - 1), for greater
accuracy than if just using a single multiplication by an
approximation to 2/sqrt(pi) (effectively, this way there are a few
more bits in the approximation to 2/sqrt(pi)).  This can introduce
underflows when efx*x underflows even though the final result does
not, so a scaled calculation with 8*efx is done in these cases - but 8
is not a big enough scale factor to avoid all such underflows.  16 is
(any underflows with a scale factor of 16 would only occur when the
final result underflows), so this patch changes the code to use that
factor.  Rather than recomputing all the values of the efx8 variable,
it is removed, leaving it to the compiler's constant folding to
compute 16*efx.  As such scaling can also lose underflows when the
final scaling down happens to be exact, appropriate checks are added
to ensure underflow exceptions occur when required in such cases.

Tested x86_64 and x86; no ulps updates needed.  Also spot-checked for
powerpc32 and mips64 to verify the changes to the ldbl-128ibm and
ldbl-128 implementations.

	[BZ #16516]
	* sysdeps/ieee754/dbl-64/s_erf.c (efx8): Remove variable.
	(__erf): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/flt-32/s_erff.c (efx8): Remove variable.
	(__erff): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-128/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-96/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* math/auto-libm-test-in: Add more tests of erf.
	* math/auto-libm-test-out: Regenerated.
2014-05-14 12:34:03 +00:00
..
aarch64 Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
alpha Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
arm Clean up ARM old-ABI symbol versioning relics. 2014-05-14 00:41:20 +00:00
generic Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
gnu Silence a missing-noreturn warning for _Unwind_Resume. 2014-05-09 10:06:20 -07:00
hppa Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
i386 Include SSE state in i386 fenv_t (bug 16064). 2014-05-09 16:59:56 +00:00
ia64 Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
ieee754 Fix erf underflow handling near 0 (bug 16516). 2014-05-14 12:34:03 +00:00
init_array Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
m68k Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
mach Some configure-related decrufting. 2014-05-08 11:27:14 -07:00
microblaze Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
mips Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
posix Fix parsing of getai result from nscd for IPv6-only request 2014-05-07 14:21:27 +02:00
powerpc PowerPC: strncpy/stpncpy optimization for PPC64/POWER7 2014-05-06 09:54:25 -05:00
pthread Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s390 S/390: Port of lock elision to System/z 2014-05-09 16:58:46 +02:00
sh Don't include individual test ulps in libm-test-ulps. 2014-03-05 15:02:38 +00:00
sparc Fix v9/64-bit strcmp when string ends in multiple zero bytes. 2014-05-01 12:15:06 -07:00
tile Clean up __exit_thread. 2014-05-13 09:49:20 -07:00
unix Fix macro warning on HAVE_PT_CHOWN 2014-05-14 09:46:54 +02: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 Include SSE state in i386 fenv_t (bug 16064). 2014-05-09 16:59:56 +00:00
x86_64 Fix -Wundef warning for FEATURE_INDEX_1. 2014-05-03 00:25:21 -04:00