Commit Graph

99 Commits

Author SHA1 Message Date
Joseph Myers ac831b362a Fix csin, csinh overflow in directed rounding modes (bug 18593).
csin and csinh can produce bad results when overflowing in directed
rounding modes, because a multiplication that can overflow is followed
by a possible negation.  This patch fixes this by negating one of the
arguments of the multiplication before the multiplication instead of
negating the result.

The new tests for this issue are added to auto-libm-test-in, starting
use of that file for csin and csinh.  The issue was found in the
course of moving existing tests for csin and csinh (existing tests, by
being enabled in more cases than previously, showed the issue for
float and double but not for long double); that move will now be done
separately.

Tested for x86_64 and x86 and ulps updated accordingly.

	[BZ #18593]
	* math/s_csin.c (__csin): Negate before rather than after possibly
	overflowing multiplication.
	* math/s_csinf.c (__csinf): Likewise.
	* math/s_csinh.c (__csinh): Likewise.
	* math/s_csinhf.c (__csinhf): Likewise.
	* math/s_csinhl.c (__csinhl): Likewise.
	* math/s_csinl.c (__csinl): Likewise.
	* math/auto-libm-test-in: Add some tests of csin and csinh.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (csin_test_data): Use AUTO_TESTS_c_c.
	(csinh_test_data): Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-06-24 16:20:48 +00:00
Joseph Myers ad39cce0da Fix sin, sincos missing underflows (bug 16526, bug 16538).
Similar to various other bugs in this area, some sin and sincos
implementations do not raise the underflow exception for subnormal
arguments, when the result is tiny and inexact.  This patch forces the
exception in a similar way to previous fixes.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #16526]
	[BZ #16538]
	* sysdeps/ieee754/dbl-64/s_sin.c: Include <float.h>.
	(__sin): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/flt-32/k_sinf.c: Include <float.h>.
	(__kernel_sinf): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/k_sincosl.c: Include <float.h>.
	(__kernel_sincosl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/k_sinl.c: Include <float.h>.
	(__kernel_sinl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/k_sincosl.c: Include <float.h>.
	(__kernel_sincosl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/k_sinl.c: Include <float.h>.
	(__kernel_sinl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-96/k_sinl.c: Include <float.h>.
	(__kernel_sinl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/powerpc/fpu/k_sinf.c: Include <float.h>.
	(__kernel_sinf): Force underflow exception for arguments with
	small absolute value.
	* math/auto-libm-test-in: Add more tests of sin and sincos.
	* math/auto-libm-test-out: Regenerated.
2015-06-23 22:24:20 +00:00
Joseph Myers 718d34a309 Fix csqrt spurious underflows (bug 18371).
The csqrt implementations in glibc can cause spurious underflows in
some cases as a side-effect of the scaling for large arguments (when
underflow is correct for the square root of the argument that was
scaled down to avoid overflow, but not for the original argument).
This patch arranges to avoid the underflowing intermediate computation
(eliminating a multiplication in 0.5 in the problem cases where a
subsequent scaling by 2 would follow).

Tested for x86_64 and x86 and ulps updated accordingly (only needed
for x86).

	[BZ #18371]
	* math/s_csqrt.c (__csqrt): Avoid multiplication by 0.5 where
	intermediate but not final result might underflow.
	* math/s_csqrtf.c (__csqrtf): Likewise.
	* math/s_csqrtl.c (__csqrtl): Likewise.
	* math/auto-libm-test-in: Add more tests of csqrt.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-06-23 16:01:54 +00:00
Joseph Myers b59549574e Fix exp2, exp2f spurious underflows (bug 18219).
The dbl-64 and flt-32 implementations of exp2 functions produce
spurious underflow exceptions.  The underlying reason is the same in
both cases: the computation works as (2^a - 1)*2^b + 2^b for suitably
chosen a and b, where a has small magnitude so 2^a - 1 can be computed
with a low-degree polynomial approximation, and (2^a - 1)*2^b can
underflow even when the final result does not.  This patch fixes this
by adjusting the threshold for when scaling is used to avoid
intermediate underflow so it works for any possible value of a where
the final result would not underflow.

Tested for x86_64 and x86.

	[BZ #18219]
	* sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Reduce
	threshold on absolute value of exponent for which scaling is used.
	* sysdeps/ieee754/flt-32/e_exp2f.c (__ieee754_exp2f): Likewise.
	* math/auto-libm-test-in: Add more tests of exp2.
	* math/auto-libm-test-out: Regenerated.
2015-06-23 14:35:18 +00:00
Joseph Myers 554edb23ff Fix expm1 missing underflows (bug 16353).
Similar to various other bugs in this area, some expm1 implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.

(The issue does not apply to the ldbl-* implementations or to those
for x86 / x86_64 long double.  The change to
sysdeps/ieee754/dbl-64/wordsize-64/e_cosh.c is one I missed when
previously fixing bug 16354; the bug in that implementation was
previously latent, but the expm1 fixes stopped it being latent and so
required it to be fixed to avoid spurious underflows from cosh.)

Tested for x86_64 and x86.

	[BZ #16353]
	* sysdeps/i386/fpu/s_expm1.S (dbl_min): New object.
	(__expm1): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/i386/fpu/s_expm1f.S (flt_min): New object.
	(__expm1f): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/dbl-64/s_expm1.c: Include <float.h>.
	(__expm1): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/flt-32/s_expm1f.c: Include <float.h>.
	(__expm1f): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/dbl-64/wordsize-64/e_cosh.c (__ieee754_cosh):
	Check for small arguments before calling __expm1.
	* math/auto-libm-test-in: Do not mark underflow exceptions as
	possibly missing for bug 16353.
	* math/auto-libm-test-out: Regenerated.
2015-06-22 21:06:19 +00:00
Joseph Myers cb0937b299 Fix x86_64 / x86 expm1l (-min_subnorm) result sign (bug 18569).
In the x86 / x86_64 implementations of expm1l, when expm1l's result
should underflow to 0 (argument minus the least subnormal, in some
rounding modes), it can be a zero of the wrong sign.  This patch fixes
this by returning the argument with underflow forced in that case
(this is a 1ulp error relative to the correctly rounded result of -0,
which is OK in terms of the documented accuracy goals, whereas a
result with the wrong sign never is).

Tested for x86_64 and x86.

	[BZ #18569]
	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]: Force
	underflow and return argument in case of subnormal argument.
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]:
	Likewise.
	* math/auto-libm-test-in: Add more tests of expm1.
	* math/auto-libm-test-out: Regenerated.
2015-06-21 18:43:10 +00:00
Joseph Myers 7540cfc5a8 Fix x86 / x86_64 expl, exp10l missing underflows (bug 16361).
Similar to various other bugs in this area, the x86 and x86_64
implementations of expl / exp10l can fail to produce underflow
exceptions when the unscaled result has trailing 0 bits so the scaling
down to subnormal precision is exact.  This patch fixes this by
forcing the exception in the case of tiny results.

Tested for x86_64 and x86.

	[BZ #16361]
	* sysdeps/i386/fpu/e_expl.S [!USE_AS_EXPM1L] (cmin): New object.
	[!USE_AS_EXPM1L] (IEEE754_EXPL): Force underflow exception for
	tiny results.
	* sysdeps/x86_64/fpu/e_expl.S [!USE_AS_EXPM1L] (cmin): New object.
	[!USE_AS_EXPM1L] (IEEE754_EXPL): Force underflow exception for
	tiny results.
	* math/auto-libm-test-in: Add more tests of exp and exp10.  Do not
	mark underflow exceptions as possibly missing for bug 16361.
	* math/auto-libm-test-out: Regenerated.
2015-06-21 17:48:04 +00:00
Joseph Myers 8db3cdefef Fix asinh missing underflows (bug 16350).
Similar to various other bugs in this area, some asinh implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.

Tested for x86_64, x86 and mips64.

	[BZ #16350]
	* sysdeps/i386/fpu/s_asinh.S (__asinh): Force underflow exception
	for arguments with small absolute value.
	* sysdeps/i386/fpu/s_asinhf.S (__asinhf): Likewise.
	* sysdeps/i386/fpu/s_asinhl.S (__asinhl): Likewise.
	* sysdeps/ieee754/dbl-64/s_asinh.c: Include <float.h>.
	(__asinh): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/flt-32/s_asinhf.c: Include <float.h>.
	(__asinhf): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/ldbl-128/s_asinhl.c: Include <float.h>.
	(__asinhl): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/ldbl-128ibm/s_asinhl.c: Include <float.h>.
	(__asinhl): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/ldbl-96/s_asinhl.c: Include <float.h>.
	(__asinhl): Force underflow exception for arguments with small
	absolute value.
	* math/auto-libm-test-in: Do not mark underflow exceptions as
	possibly missing for bug 16350.
	* math/auto-libm-test-out: Regenerated.
2015-06-18 23:27:41 +00:00
Joseph Myers a1ee4fd106 Remove stray spurious-underflow markings from cexp test.
I noticed that I'd left a spurious-underflow allowance behind in
auto-libm-test-in for a bug that was fixed some time ago.  This patch
removes it.

Tested for x86_64 and x86.

	* math/auto-libm-test-in: Remove spurious underflow allowance for
	tests of cexp.
	* math/auto-libm-test-out: Regenerated.
2015-06-18 20:51:17 +00:00
Joseph Myers 526af54142 Fix i386 atanhl spurious underflows (bug 18049).
The i386 implementation of atanhl, for small arguments, does a
calculation that involves computing twice the square of the argument,
resulting in spurious underflows for some arguments.  This patch fixes
this by just returning the argument when its exponent is below -32,
with underflow being forced as needed for subnormal arguments.

Tested for x86 and x86_64.

	[BZ #18049]
	* sysdeps/i386/fpu/e_atanhl.S (__ieee754_atanhl): For exponents
	below -32, return the argument, with underflow if subnormal.
	* math/auto-libm-test-in: Add more tests of atanh.
	* math/auto-libm-test-out: Regenerated.
2015-05-19 23:05:22 +00:00
Joseph Myers 8020a80887 Fix atanhl missing underflows (bug 16352).
Similar to various other bugs in this area, some atanh implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.  (No change in this regard is needed
for the i386 implementation; special handling to force underflows in
these cases will only be needed there when the spurious underflows,
bug 18049, get fixed.)

Tested for x86_64, x86, powerpc and mips64.

	[BZ #16352]
	* sysdeps/i386/fpu/e_atanh.S (dbl_min): New object.
	(__ieee754_atanh): Force underflow exception for results with
	small absolute value.
	* sysdeps/i386/fpu/e_atanhf.S (flt_min): New object.
	(__ieee754_atanhf): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/dbl-64/e_atanh.c: Include <float.h>.
	(__ieee754_atanh): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/flt-32/e_atanhf.c: Include <float.h>.
	(__ieee754_atanhf): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/e_atanhl.c: Include <float.h>.
	(__ieee754_atanhl): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/e_atanhl.c: Include <float.h>.
	(__ieee754_atanhl): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-96/e_atanhl.c: Include <float.h>.
	(__ieee754_atanhl): Force underflow exception for results with
	small absolute value.
	* math/auto-libm-test-in: Do not allow missing underflow
	exceptions from atanh.
	* math/auto-libm-test-out: Regenerated.
2015-05-15 22:07:57 +00:00
Joseph Myers 5a608ccc2d Fix tanf spurious underflows (bug 18221).
The flt-32 implementation of tanf produces spurious underflow
exceptions for some small arguments, through computing values on the
order of x^5.  This patch fixes this by adjusting the threshold for
returning x (or, as applicable, +/- 1/x) to 2**-13 (the next term in
the power series being x^3/3).

Tested for x86_64 and x86.

	[BZ #18221]
	* sysdeps/ieee754/flt-32/k_tanf.c (__kernel_tanf): Use 2**-13 not
	2**-28 as threshold for returning x or +/- 1/x.
	* math/auto-libm-test-in: Add more tests of tan.
	* math/auto-libm-test-out: Regenerated.
2015-05-15 17:47:29 +00:00
Joseph Myers ff069f024a Fix lgammaf spurious underflows (bug 18220).
The flt-32 implementation of lgammaf produces spurious underflow
exceptions for some large arguments, because of calculations involving
x^-2 multiplied by small constants.  This patch fixes this by
adjusting the threshold for a simpler computation to 2**26 (the error
in the simpler computation is on the order of 0.5 * log (x), for a
result on the order of x * log (x)).

Tested for x86_64 and x86.

	[BZ #18220]
	* sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Use
	2**26 not 2**58 as threshold for returning x * (log (x) - 1).
	* math/auto-libm-test-in: Add another test of lgamma.
	* math/auto-libm-test-out: Regenerated.
2015-05-15 17:21:08 +00:00
Joseph Myers fbc68f03b0 Fix erfcf spurious underflows (bug 18217).
The flt-32 implementation of erfcf produces spurious underflow
exceptions for some arguments close to 0, because of calculations
squaring the argument and then multiplying by small constants.  This
patch fixes this by adjusting the threshold for arguments for which
the result is so close to 1 that 1 - x will give the right result from
2**-56 to 2**-26.  (If 1 - x * 2/sqrt(pi) were used, the errors would be
on the order of x^3 and a much larger threshold could be used.)

Tested for x86_64 and x86.

	[BZ #18217]
	* sysdeps/ieee754/flt-32/s_erff.c (__erfcf): Use 2**-26 not 2**-56
	as threshold for returning 1 - x.
	* math/auto-libm-test-in: Add more tests of erfc.
	* math/auto-libm-test-out: Regenerated.
2015-05-15 00:16:10 +00:00
Joseph Myers 9a71f1fcf5 Fix atanf spurious underflows (bug 18196).
The sysdeps/ieee754/flt-32 version of atanf produces spurious
underflow exceptions for some large arguments, because of computations
that compute x^-4.  This patch fixes this by adjusting the threshold
for large arguments (for which +/- pi/2 can just be returned, the
correct result being roughly +/- pi/2 - 1/x) from 2^34 to 2^25.

Tested for x86_64 and x86.

	[BZ #18196]
	* sysdeps/ieee754/flt-32/s_atanf.c (__atanf): Use 2^25 not 2^34 as
	threshold for large arguments.
	* math/auto-libm-test-in: Add another test of atan.
	* math/auto-libm-test-out: Regenerated.
2015-05-14 23:51:09 +00:00
Joseph Myers 0b7a5f9201 Fix log1p missing underflows (bug 16339).
Similar to various other bugs in this area, some log1p implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.  (The ldbl-128ibm implementation
doesn't currently need any change as it already generates this
exception, albeit through code that would generate spurious exceptions
in other cases; special code for this issue will only be needed there
when fixing the spurious exceptions.)

Tested for x86_64, x86, powerpc and mips64.

	[BZ #16339]
	* sysdeps/i386/fpu/s_log1p.S (dbl_min): New object.
	(__log1p): Force underflow exception for results with small
	absolute value.
	* sysdeps/i386/fpu/s_log1pf.S (flt_min): New object.
	(__log1pf): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/dbl-64/s_log1p.c: Include <float.h>.
	(__log1p): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/flt-32/s_log1pf.c: Include <float.h>.
	(__log1pf): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/ldbl-128/s_log1pl.c: Include <float.h>.
	(__log1pl): Force underflow exception for results with small
	absolute value.
	* math/auto-libm-test-in: Do not allow missing underflow
	exceptions from log1p.
	* math/auto-libm-test-out: Regenerated.
2015-05-14 23:38:07 +00:00
Joseph Myers 14f36098f2 Add more tests of csqrt, lgamma, log10, sinh.
This patch adds more randomly-generated tests of various libm
functions that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of csqrt, lgamma, log10
	and sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-08 17:55:11 +00:00
Joseph Myers 471dffa12c Add more tests of acosh, atanh, cos, csqrt, erfc, sin, sincos.
This patch adds more randomly-generated tests of various libm
functions that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of acosh, atanh, cos,
	csqrt, erfc, sin and sincos.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-06 17:30:18 +00:00
Joseph Myers 31450d9a87 Add further tests of libm functions.
This patch adds more randomly-generated tests of various libm
functions that are observed to increase ulps on x86_64.  (This process
must eventually converge, when my random test generation stops finding
inputs that increase the listed ulps, except maybe for any cases
uncovered where the errors exceed the maximum allowed 9ulp error and
so indicate actual libm bugs needing fixing.)

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of acosh, atanh, clog,
	clog10, csqrt, erfc, exp2, expm1, log10, log2 and sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-05 22:59:41 +00:00
Joseph Myers 305392eaca Add more tests of libm functions.
This patch adds more randomly-generated tests of various libm
functions that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of atan, clog, clog10,
	cos, csqrt, erf, erfc, exp2, lgamma, log1p, sin, sincos, tanh and
	tgamma.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-02 21:06:33 +00:00
Joseph Myers 51e15247c3 Add more tests of tgamma.
This patch adds some randomly-generated tests of tgamma that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of tgamma.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 23:15:07 +00:00
Joseph Myers 5ffb9a53d7 Add more tests of tanh.
This patch adds some randomly-generated tests of tanh that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of tanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 23:06:44 +00:00
Joseph Myers 0957e15d0a Add more tests of tan.
This patch adds some randomly-generated tests of tan that are observed
to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of tan.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 22:54:39 +00:00
Joseph Myers 827bb5859c Add more tests of cos, sin, sincos.
This patch adds some randomly-generated tests of cos, sin and sincos
that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cos, sin and sincos.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 22:41:00 +00:00
Joseph Myers 86793ae758 Add another test of pow.
This patch adds a randomly-generated test of pow that is observed to
increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add another test of pow.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-05-01 22:31:24 +00:00
Joseph Myers 038e4be99c Add more tests of lgamma.
This patch adds some randomly-generated tests of lgamma that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of lgamma.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 22:17:19 +00:00
Joseph Myers a0d31f36aa Add more tests of log, log10, log1p, log2.
This patch adds some randomly-generated tests of log, log10, log1p and
log2 that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of log, log10, log2 and
	log1p.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 21:08:37 +00:00
Joseph Myers e1483b365d Add more tests of exp, exp10, exp2, expm1.
This patch adds some randomly-generated tests of exp, exp10, exp2 and
expm1 that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of exp, exp10, exp2 and
	expm1.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 20:33:04 +00:00
Joseph Myers c5a3a509df Add more tests of erf, erfc.
This patch adds some randomly-generated tests of erf and erfc that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of erf and erfc.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 17:49:44 +00:00
Joseph Myers 9862ab1f67 Add more tests of csqrt.
This patch adds some randomly-generated tests of csqrt that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of csqrt.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-30 22:51:29 +00:00
Joseph Myers 094fca83ee Add further tests of cosh and sinh.
This patch adds some further randomly-generated tests of cosh and sinh
that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cosh and sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-30 22:32:08 +00:00
Joseph Myers b3c66c534f Add more tests of clog and clog10.
This patch adds some randomly-generated tests of clog and clog10 that
are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of clog and clog10.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-09 22:14:34 +00:00
Joseph Myers 787d22bce6 Add more tests of atanh.
This patch adds some randomly-generated tests of atanh that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of atanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-08 21:13:35 +00:00
Joseph Myers 024bcc5106 Add more tests of atan.
This patch adds some randomly-generated tests of atan that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of atan.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-08 21:00:03 +00:00
Joseph Myers da0cf658c6 Add more tests of cbrt.
This patch adds some randomly-generated tests of cbrt that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cbrt.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-04-08 17:56:15 +00:00
Joseph Myers 80352c01c1 Add more tests of cabs.
This patch adds some randomly-generated tests of cabs that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cabs.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-08 17:46:07 +00:00
Joseph Myers 8431838dde Fix dbl-64 atan2 in non-default rounding modes (bug 18210, bug 18211).
The dbl-64 implementation of atan2 does computations that expect to
run in round-to-nearest mode, and in other modes the errors can
accumulate to more than the maximum accepted 9ulp.  This patch makes
it use FE_TONEAREST internally, similar to other functions with such
issues.  Tests that previously produced large errors are added for
atan2 and the closely related carg, clog and clog10 functions.

Tested for x86_64 and x86 and ulps updated accordingly.

	[BZ #18210]
	[BZ #18211]
	* sysdeps/ieee754/dbl-64/e_atan2.c: Include <fenv.h>.
	(__ieee754_atan2): Set FE_TONEAREST mode for internal
	computations.
	* math/auto-libm-test-in: Add more tests of atan2, carg, clog and
	clog10.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-08 17:32:17 +00:00
Joseph Myers ae63c7ebed Fix dbl-64 atan in non-default rounding modes (bug 18197).
The dbl-64 implementation of atan does computations that expect to run
in round-to-nearest mode, and in other modes the errors can accumulate
to more than the maximum accepted 9ulp.  This patch makes it use
FE_TONEAREST internally, similar to other functions with such issues.

Tested for x86_64 and x86; no ulps updates needed.

	[BZ #18197]
	* sysdeps/ieee754/dbl-64/s_atan.c: Include <fenv.h>.
	(atan): Set FE_TONEAREST mode for internal computations.
	* math/auto-libm-test-in: Add more tests of atan.
	* math/auto-libm-test-out: Regenerated.
2015-04-08 17:14:12 +00:00
Joseph Myers efd5b641dd Add more tests of acosh, asinh and atanh.
This patch adds some randomly-generated tests of acosh, asinh and
atanh that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of acosh, asinh and
	atanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 22:21:20 +00:00
Joseph Myers e9b1015112 Add another test of asin.
This patch adds a randomly-generated test of asin that is observed to
increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add another test of asin.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 21:57:04 +00:00
Joseph Myers 38755f1421 Add more tests of asin.
This patch adds some randomly-generated tests of asin that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of asin.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 17:53:58 +00:00
Joseph Myers 8d6439712d Add more tests of acos.
This patch adds some randomly-generated tests of acos that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of acos.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 00:30:10 +00:00
Joseph Myers bc899ea090 Add more tests of expm1.
This patch adds some randomly-generated tests of expm1 that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of expm1.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 00:05:13 +00:00
Joseph Myers 239ed6f309 Add more tests of cosh, sinh.
This patch adds some randomly-generated tests of cosh and sinh that
are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cosh and sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-24 23:48:04 +00:00
Joseph Myers 7c84a5042f Add more tests of log2.
In testing for x86_64 on an AMD processor, I observed libm test
failures of the form:

testing long double (without inline functions)
Failure: Test: log2_downward (0x2.b7e151628aed4p+0)
Result:
 is:          1.44269504088896356633e+00   0xb.8aa3b295c17f67600000p-3
 should be:   1.44269504088896356622e+00   0xb.8aa3b295c17f67500000p-3
 difference:  1.08420217248550443400e-19   0x8.00000000000000000000p-66
 ulp       :  1.0000
 max.ulp   :  0.0000
Maximal error of `log2_downward'
 is      : 1 ulp
 accepted: 0 ulp

These issues arise because the maximum ulps when regenerating on one
processor are not the same as on another processor, so regeneration on
several processors may be needed when updating libm-test-ulps to avoid
failures for some users testing glibc - but such regeneration on
multiple processors is inconvenient.  Causes can be: on x86 and, for
x86_64, for long double, variation in results of x87 instructions for
transcendental operations between processors; on x86, variation in
compiler excess precision between compiler versions and
configurations; on any processor where the compiler may contract
expressions using fused multiply-add, variation in what contraction
occurs.

Although it's hard to be sure libm-test-ulps covers all ulps that may
be seen in any configuration for the given architecture, in practice
it helps simply to add wider test coverage to make it more likely
that, when testing on one processor, the ulps seen are the biggest
that can be seen for that function on that processor, and hopefully
they are also the biggest that can be seen for that function in other
configurations for that architecture.  Thus, this patch adds some
tests of log2 that increase the ulps I see on x86_64 on an Intel
processor, so that hopefully future from-scratch regenerations on that
processor will produce ulps big enough not to have errors from testing
on AMD processors.  These tests were found by randomly generating
inputs and seeing what produced ulps larger than those currently in
libm-test-ulps.  Of course such increases also improve the accuracy of
the empirical table of known ulps generated from libm-test-ulps files
that goes in the manual.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of log2.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-24 23:06:28 +00:00
Joseph Myers 6411f81da9 Add test for bug 18104.
[BZ #18104]
	* math/auto-libm-test-in: Add another test of pow.
	* math/auto-libm-test-out: Regenerated.
2015-03-10 17:53:40 +00:00
Joseph Myers 2ca725c594 Fix ldbl-96, ldbl-128ibm atanhl inaccuracy (bug 18046, bug 18047).
The threshold in ldbl-96 atanhl for when to return the argument,
0x1p-28, is a bit too big, and that in ldbl-128ibm atanhl is much too
big (the relevant condition being x^3/3 being < 0.5ulp of x),
resulting in errors a bit above the limits of those considered
acceptable in glibc in the ldbl-96 case, and in large errors in the
ldbl-128ibm case.  This patch changes those implementations to use
more appropriate thresholds and adds tests around the thresholds for
various formats.

Tested for x86_64, x86 and powerpc.  x86_64 and x86 ulps updated
accordingly.

	[BZ #18046]
	[BZ #18047]
	* sysdeps/ieee754/ldbl-128ibm/e_atanhl.c (__ieee754_atanhl): Use
	0x1p-56L as threshold for just returning the argument.
	* sysdeps/ieee754/ldbl-96/e_atanhl.c (__ieee754_atanhl): Use
	0x1p-32L as threshold for just returning the argument.
	* math/auto-libm-test-in: Add more tests of atanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulp: Likewise.
2015-02-27 17:48:37 +00:00
Joseph Myers 1d9ab20c14 Fix ldbl-128/ldbl-128ibm acosl inaccuracy (bug 18038, bug 18039).
The ldbl-128 and ldbl-128ibm implementations of acosl have similar
bugs, using a threshold of 0x1p-57L to determine when they just return
pi/2.  Since the result pi/2 - asinl (x) is roughly pi/2 - x for small
x, the relevant cut-off is actually x being < 0.5ulp of 1.  This patch
fixes the implementations to use that cut-off and adds tests of small
acos arguments.

Tested for powerpc and mips64.  Also tested for x86_64 and x86; no
ulps updates needed.

	[BZ #18038]
	[BZ #18039]
	* sysdeps/ieee754/ldbl-128/e_acosl.c (__ieee754_acosl): Only
	return pi/2 for arguments below 0x1p-113L.
	* sysdeps/ieee754/ldbl-128ibm/e_acosl.c (__ieee754_acosl): Only
	return pi/2 for arguments below 0x1p-106L.
	* math/auto-libm-test-in: Add more tests of acos.
	* math/auto-libm-test-out: Regenerated.
2015-02-26 21:06:34 +00:00
Joseph Myers ec0ce0d3be Fix asin missing underflows (bug 16351).
Similar to various other bugs in this area, some asin implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.

Tested for x86_64, x86, powerpc and mips64.

	[BZ #16351]
	* sysdeps/i386/fpu/e_asin.S (dbl_min): New object.
	(MO): New macro.
	(__ieee754_asin): Force underflow exception for results with small
	absolute value.
	* sysdeps/i386/fpu/e_asinf.S (flt_min): New object.
	(MO): New macro.
	(__ieee754_asinf): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/dbl-64/e_asin.c: Include <float.h> and <math.h>.
	(__ieee754_asin): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/flt-32/e_asinf.c: Include <float.h>.
	(__ieee754_asinf): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/e_asinl.c: Include <float.h>.
	(__ieee754_asinl): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/e_asinl.c: Include <float.h>.
	(__ieee754_asinl): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-96/e_asinl.c: Include <float.h>.
	(__ieee754_asinl): Force underflow exception for results with
	small absolute value.
	* sysdeps/x86_64/fpu/multiarch/e_asin.c [HAVE_FMA4_SUPPORT]:
	Include <math.h>.
	* math/auto-libm-test-in: Do not mark underflow exceptions as
	possibly missing for bug 16351.
	* math/auto-libm-test-out: Regenerated.
2015-02-26 17:18:54 +00:00
Joseph Myers 137cef7d43 Fix ldbl-128ibm asinhl inaccuracy (bug 18020).
The ldbl-128ibm implementation of asinhl uses cut-offs of 0x1p28 and
0x1p-29 to determine when to use simpler formulas that avoid possible
overflow / underflow.  Both those cut-offs are inappropriate for this
format, resulting in large errors.  This patch changes the code to use
more appropriate cut-offs of 0x1p56 and 0x1p-56, adding tests around
the cut-offs for various floating-point formats.

Tested for powerpc.  Also tested for x86_64 and x86 and updated ulps.

	[BZ #18020]
	* sysdeps/ieee754/ldbl-128ibm/s_asinhl.c (__asinhl): Use 2**56 and
	2**-56 not 2**28 and 2**-29 as thresholds for simpler formulas.
	* math/auto-libm-test-in: Add more tests of asinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-02-25 11:13:41 +00:00