glibc/sysdeps/ieee754/flt-32
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
..
e_acosf.c
e_acoshf.c
e_asinf.c
e_atan2f.c
e_atanhf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_coshf.c
e_exp2f.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
e_expf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
e_fmodf.c
e_gammaf_r.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_hypotf.c
e_ilogbf.c
e_j0f.c
e_j1f.c
e_jnf.c Fix spurious jnf underflows (bug 14155). 2013-09-02 14:51:24 +00:00
e_lgammaf_r.c Fix lgammaf spurious underflow (bug 15427). 2013-09-03 15:32:54 +00:00
e_log2f.c
e_log10f.c
e_logf.c Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800). 2014-04-02 17:41:02 +00:00
e_powf.c
e_rem_pio2f.c Fix leading whitespaces. 2013-06-06 20:36:07 +02:00
e_remainderf.c
e_sinhf.c
e_sqrtf.c
k_cosf.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
k_rem_pio2f.c Fix leading whitespaces. 2013-06-06 20:36:07 +02:00
k_sinf.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
k_tanf.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
math_private.h
mpn2flt.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_asinhf.c
s_atanf.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
s_cbrtf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_ceilf.c
s_copysignf.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
s_cosf.c
s_erff.c Fix erf underflow handling near 0 (bug 16516). 2014-05-14 12:34:03 +00:00
s_expm1f.c
s_fabsf.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
s_finitef.c PowerPC: multiarch finite/finitef for PowerPC32 2013-12-06 05:47:03 -06:00
s_floorf.c
s_fpclassifyf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_frexpf.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
s_isinf_nsf.c
s_isinff.c
s_isnanf.c
s_issignalingf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_llrintf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_llroundf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_log1pf.c [BZ #16823] Fix log1pl returning wrong infinity sign 2014-04-29 15:43:36 +02:00
s_logbf.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_lrintf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_lroundf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_modff.c
s_nearbyintf.c Fix nearbyint scheduling of arithmetic past fesetenv (bug 15490). 2013-05-19 18:40:25 +00:00
s_nextafterf.c Fix nextafter overflow in non-default rounding modes (bug 16677). 2014-03-11 22:24:00 +00:00
s_remquof.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_rintf.c
s_roundf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_scalblnf.c
s_scalbnf.c
s_signbitf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_sincosf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_sinf.c
s_tanf.c
s_tanhf.c
s_truncf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
t_exp2f.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
w_expf.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00