glibc/sysdeps/ieee754/ldbl-96
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_acoshl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_asinl.c Use hex float 64-bit values in ldbl-96 asinl (bug 14803). 2012-11-28 21:46:16 +00:00
e_atanhl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_coshl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_gammal_r.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_hypotl.c Fix hypot handling of subnormals (bug 16316, bug 16330). 2013-12-17 13:42:13 +00:00
e_j0l.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_j1l.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_jnl.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_lgammal_r.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_rem_pio2l.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
e_sinhl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
gamma_product.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
gamma_productl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
k_cosl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
k_sinl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
k_tanl.c Fix tan, tanl for large inputs. 2012-03-16 20:05:37 +00:00
ldbl2mpn.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
math_ldbl.h Fix a typo. 2000-12-21 23:30:28 +00:00
mpn2ldbl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
printf_fphex.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_asinhl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_cbrtl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_copysignl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_cosl.c Implement ldbl-96 sinl / cosl / sincosl (bug 13851). 2012-03-16 12:30:05 +00:00
s_erfl.c Fix erf underflow handling near 0 (bug 16516). 2014-05-14 12:34:03 +00:00
s_fma.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_fmal.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_frexpl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_isinf_nsl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_issignalingl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_llrintl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_llroundl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_lrintl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_lroundl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_modfl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_nexttoward.c Fix nexttoward bugs (bugs 2550, 2570). 2012-05-01 15:37:43 +00:00
s_nexttowardf.c Fix nexttoward bugs (bugs 2550, 2570). 2012-05-01 15:37:43 +00:00
s_remquol.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_roundl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_scalblnl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_signbitl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_sincosl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
s_sinl.c Implement ldbl-96 sinl / cosl / sincosl (bug 13851). 2012-03-16 12:30:05 +00:00
s_tanhl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_tanl.c Fix tan, tanl for large inputs. 2012-03-16 20:05:37 +00:00
strtold_l.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
t_sincosl.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
w_expl.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
x2y2m1l.c Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00