Commit Graph

366 Commits

Author SHA1 Message Date
Joseph Myers 863893ec95 Test cpow in all rounding modes.
This patch enables testing of cpow in all rounding modes using
ALL_RM_TEST.  There were two reasons this was previously deferred:

* MPC has complicated rounding-mode-dependent rules for the signs of
  exact zero real or imaginary parts in the result of mpc_pow.  Annex
  G does not impose any such requirements and I don't think glibc
  should try to implement any particular logic here.  This patch adds
  support for gen-auto-libm-tests passing the IGNORE_ZERO_INF_SIGN
  flag to libm-test.inc.

* Error accumulations in some tests in non-default rounding modes
  exceed the maximum error permitted in libm-test.inc.  This patch
  marks the problem tests with xfail-rounding.  (It might be possible
  to reduce the accumulations a bit by using round-to-nearest when
  cpow calls clog, but I don't think there's much point; the
  implementation approach for cpow is fundamentally deficient, as
  discussed in the existing bug for cpow inaccuracy which can
  reasonably be considered to cover these less-inaccurate cases as
  well.  It's possible that the test "cpow 2 0 10 0" will also need
  xfail-rounding on some platforms.)

Tested x86_64 and x86 and ulps updated accordingly.

	* math/gen-auto-libm-tests.c: Document use of
	ignore-zero-inf-sign.
	(input_flag_type): Add value flag_ignore_zero_inf_sign.
	(input_flags): Add ignore-zero-inf-sign.
	(output_for_one_input_case): Handle flag_ignore_zero_inf_sign.
	* math/gen-libm-test.pl (generate_testfile): Handle
	ignore-zero-inf-sign.
	* math/auto-libm-test-in: Mark some cpow tests with
	ignore-zero-inf-sign and some with xfail-rounding.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (cpow_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-06-23 20:15:14 +00:00
Joseph Myers 4da6db5188 Fix pow overflow in non-default rounding modes (bug 16315).
This patch fixes bug 16315, bad pow handling of overflow/underflow in
non-default rounding modes.  Tests of pow are duly converted to
ALL_RM_TEST to run all tests in all rounding modes.

There are two main issues here.  First, various implementations
compute a negative result by negating a positive result, but this
yields inappropriate overflow / underflow values for directed
rounding, so either overflow / underflow results need recomputing in
the correct sign, or the relevant overflowing / underflowing operation
needs to be made to have a result of the correct sign.  Second, the
dbl-64 implementation sets FE_TONEAREST internally; in the overflow /
underflow case, the result needs recomputing in the original rounding
mode.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16315]
	* sysdeps/i386/fpu/e_pow.S (__ieee754_pow): Ensure possibly
	overflowing or underflowing operations take place with sign of
	result.
	* sysdeps/i386/fpu/e_powf.S (__ieee754_powf): Likewise.
	* sysdeps/i386/fpu/e_powl.S (__ieee754_powl): Likewise.
	* sysdeps/ieee754/dbl-64/e_pow.c: Include <math.h>.
	(__ieee754_pow): Recompute overflowing and underflowing results in
	original rounding mode.
	* sysdeps/x86/fpu/powl_helper.c: Include <stdbool.h>.
	(__powl_helper): Allow negative argument X and scale negated value
	as needed.  Avoid passing value outside [-1, 1] to f2xm1.
	* sysdeps/x86_64/fpu/e_powl.S (__ieee754_powl): Ensure possibly
	overflowing or underflowing operations take place with sign of
	result.
	* sysdeps/x86_64/fpu/multiarch/e_pow.c [HAVE_FMA4_SUPPORT]:
	Include <math.h>.
	* math/auto-libm-test-in: Add more tests of pow.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (pow_test): Use ALL_RM_TEST.
	(pow_tonearest_test_data): Remove.
	(pow_test_tonearest): Likewise.
	(pow_towardzero_test_data): Likewise.
	(pow_test_towardzero): Likewise.
	(pow_downward_test_data): Likewise.
	(pow_test_downward): Likewise.
	(pow_upward_test_data): Likewise.
	(pow_test_upward): Likewise.
	(main): Don't call removed functions.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-06-23 20:12:33 +00:00
Stefan Liebler 3ef6b85059 [BZ #6803] Set errno for scalbln, scalbn
Errno is not set and the testcases will fail.

Now the scalbln-aliases are removed in i386/m68
and the wrappers are used when calling the scalbln-functions.

On ia64 only scalblnf has its own implementation.
For scalbln and scalblnl the ieee754/dbl-64 and ieee754/ldbl-96 are used, thus
the wrappers are needed, too.
2014-06-20 07:48:20 +05:30
Rajalakshmi Srinivasaraghavan 754c5a08aa PowerPC: Fix nearbyintl failure for few inputs
This patch fixes few failures in nearbyintl() where the fraction part is
close to 0.5.i  The new tests added report few extra failures in
nearbyint_downward and nearbyint_towardzero which is a known issue.

Fixes #17031.
2014-06-17 08:46:25 -05:00
Joseph Myers f8ba1b5654 Fix log2 (1) in round-downward mode (bug 17042).
As with other issues of this kind, bug 17042 is log2 (1) wrongly
returning -0 instead of +0 in round-downward mode because of
implementations effectively in terms of log1p (x - 1).  This patch
fixes the issue in the same way used for log and log10.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 to confirm a fix was needed for ldbl-128 and to validate that
fix (also applied to ldbl-128ibm since that version of log2l is
essentially the same as the ldbl-128 one).

	[BZ #17042]
	* sysdeps/i386/fpu/e_log2.S (__ieee754_log2): Take absolete value
	when x - 1 is zero.
	* sysdeps/i386/fpu/e_log2f.S (__ieee754_log2f): Likewise.
	* sysdeps/i386/fpu/e_log2l.S (__ieee754_log2l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Return
	0.0L for an argument of 1.0L.
	* sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l):
	Likewise.
	* sysdeps/x86_64/fpu/e_log2l.S (__ieee754_log2l): Take absolute
	value when x - 1 is zero.
	* math/libm-test.inc (log2_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-06-10 12:07:15 +00:00
Joseph Myers b72592e75f Fix log10 (1) in round-downward mode (bug 16977).
As with various other issues of this kind, bug 16977 is log10 (1)
wrongly returning -0 rather than +0 in round-downward mode because of
an implementation effectively in terms of log1p (x - 1).  This patch
fixes the issue in the same way used for log.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 to confirm a fix was needed for ldbl-128 and to validate that
fix (also applied to ldbl-128ibm since that version of logl is
essentially the same as the ldbl-128 one).

	[BZ #16977]
	* sysdeps/i386/fpu/e_log10.S (__ieee754_log10): Take absolute
	value when x - 1 is zero.
	* sysdeps/i386/fpu/e_log10f.S (__ieee754_log10f): Likewise.
	* sysdeps/i386/fpu/e_log10l.S (__ieee754_log10l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log10l.c (__ieee754_log10l): Return
	0.0L for an argument of 1.0L.
	* sysdeps/ieee754/ldbl-128ibm/e_log10l.c (__ieee754_log10l):
	Likewise.
	* sysdeps/x86_64/fpu/e_log10l.S (__ieee754_log10l): Take absolute
	value when x - 1 is zero.
	* math/libm-test.inc (log10_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-23 12:07:50 +00:00
Joseph Myers 01dbacd22a Fix cacos (+Inf + finite*i) in round-downward mode (bug 16928).
According to C99/C11 Annex G, cacos applied to a value with real part
+Inf and finite imaginary part should produce a result with real part
+0.  glibc wrongly produces a result with real part -0 in FE_DOWNWARD
mode.  This patch fixes this by checking for zero results in the
relevant case of non-finite arguments (where there should never be a
result with -0 real part), and converts the tests of cacos to
ALL_RM_TEST.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16928]
	* math/s_cacos.c (__cacos): Ensure zero real part of result from
	non-finite arguments is +0.
	* math/s_cacosf.c (__cacosf): Likewise.
	* math/s_cacosl.c (__cacosl): Likewise.
	* math/libm-test.inc (cacos_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-14 12:37:24 +00:00
Joseph Myers 913d03c864 Fix acosh (1) in round-downward mode (bug 16927).
According to C99 and C11 Annex F, acosh (1) should be +0 in all
rounding modes.  However, some implementations in glibc wrongly return
-0 in round-downward mode (which is what you get if you end up
computing log1p (-0), via 1 - 1 being -0 in round-downward mode).
This patch fixes the problem implementations, by correcting the test
for an exact 1 value in the ldbl-96 implementation to allow for the
explicit high bit of the mantissa, and by inserting fabs instructions
in the i386 implementations; tests of acosh are duly converted to
ALL_RM_TEST.  I believe all the other sysdeps/ieee754 implementations
are already OK (I haven't checked the ia64 versions, but if buggy then
that will be obvious from the results of test runs after this patch is
in).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16927]
	* sysdeps/i386/fpu/e_acosh.S (__ieee754_acosh): Use fabs on x-1
	value.
	* sysdeps/i386/fpu/e_acoshf.S (__ieee754_acoshf): Likewise.
	* sysdeps/i386/fpu/e_acoshl.S (__ieee754_acoshl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_acoshl.c (__ieee754_acoshl): Correct
	for explicit high bit of mantissa when testing for argument equal
	to 1.
	* math/libm-test.inc (acosh_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-14 12:35:40 +00:00
Alan Modra aa5f0ff11a Correct IBM long double frexpl.
Besides fixing the bugzilla, this also fixes corner-cases where the high
and low double differ greatly in magnitude, and handles a denormal
input without resorting to a fp rescale.

	[BZ #16740]
	[BZ #16619]
	* sysdeps/ieee754/ldbl-128ibm/s_frexpl.c (__frexpl): Rewrite.
	* math/libm-test.inc (frexp_test_data): Add tests.
2014-04-16 19:33:32 +09:30
Joseph Myers a84e78c8b3 Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800).
This patch fixes incorrect results from catan and catanh of certain
special inputs in round-downward mode (bug 16799), and incorrect
results of __ieee754_logf (+/-0) in round-downward mode (bug 16800)
that show up through catan/catanh when tested in all rounding modes,
but not directly in the testing for logf because the bug gets hidden
by the wrappers.

Both bugs involve a zero that should be +0 being -0 instead: one
computed as (1-x)*(1+x) in the catan/catanh case, and one as (x-x) in
the logf case.  The fixes ensure positive zero is used.  Testing of
catan and catanh in all rounding modes is duly enabled.

I expect there are various other bugs in special cases in __ieee754_*
functions that are normally hidden by the wrappers but would show up
for testing with -lieee (or in future with -fno-math-errno if we
replace -lieee and _LIB_VERSION with compile-time redirection to new
*_noerrno symbol names).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16799]
	[BZ #16800]
	* math/s_catan.c (__catan): Avoid passing -0 denominator to atan2
	with 0 numerator.
	* math/s_catanf.c (__catanf): Likewise.
	* math/s_catanh.c (__catanh): Likewise.
	* math/s_catanhf.c (__catanhf): Likewise.
	* math/s_catanhl.c (__catanhl): Likewise.
	* math/s_catanl.c (__catanl): Likewise.
	* sysdeps/ieee754/flt-32/e_logf.c (__ieee754_logf): Always divide
	by positive zero when computing -Inf result.
	* math/libm-test.inc (catan_test): Use ALL_RM_TEST.
	(catanh_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-04-02 17:41:02 +00:00
Joseph Myers 6f05bafeba Fix clog / clog10 sign of zero result in round-downward mode (bug 16789).
This patch fixes bug 16789, incorrect sign of (real part) zero result
from clog and clog10 in round-downward mode, arising from that real
part being computed as 0 - 0.  To ensure that an underflow exception
occurred, the code used an underflowing value (the next term in the
series for log1p) in arithmetic computing the real part of the result,
yielding the problematic 0 - 0 computation in some cases even when the
mathematical result would be small but positive.  The patch changes
this code to use the math_force_eval approach to ensuring that an
underflowing computation actually occurs.  Tests of clog and clog10
are enabled in all rounding modes.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16789]
	* math/s_clog.c (__clog): Use math_force_eval to ensure underflow
	instead of using underflowing value in computing result.
	* math/s_clog10.c (__clog10): Likewise.
	* math/s_clog10f.c (__clog10f): Likewise.
	* math/s_clog10l.c (__clog10l): Likewise.
	* math/s_clogf.c (__clogf): Likewise.
	* math/s_clogl.c (__clogl): Likewise.
	* math/libm-test.inc (clog_test): Use ALL_RM_TEST.
	(clog10_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-04-02 13:10:19 +00:00
Alan Modra b0abbc2103 Correct IBM long double nextafterl.
Fix for values near a power of two, and some tidies.

	[BZ #16739]
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl): Correct
	output when value is near a power of two.  Use int64_t for lx and
	remove casts.  Use decimal rather than hex exponent constants.
	Don't use long double multiplication when double will suffice.
	* math/libm-test.inc (nextafter_test_data): Add tests.
	* NEWS: Add 16739 and 16786 to bug list.
2014-04-02 13:46:19 +10:30
Joseph Myers 8795b4a443 Set errno for scalb errors (bug 6803, bug 6804).
This patch fixes the default mode of scalb to set errno (bugs 6803 and
6804).

Previously, the _LIB_VERSION == _SVID_ mode would set errno but only
in some relevant cases, and with various peculiarities (such as errno
setting when an exact infinity or zero result arises with an argument
to scalb being an infinity).  This patch leaves this mode
bug-compatible, while making the default mode set errno in accordance
with normal practice (so an exact infinity from an infinite argument
is not an error, and nor is an exact zero result).  gen-libm-test.pl
is taught new notation such as ERRNO_PLUS_OFLOW to facilitate writing
the tests of errno setting for underflow / overflow in libm-test.inc.

Note that bug 6803 also covers scalbn and scalbln, but this patch only
addresses the scalb parts of that bug (along with the whole of bug
6804).

Tested x86_64 and x86.

	[BZ #6803]
	[BZ #6804]
	* math/w_scalb.c (__scalb): For non-SVID mode, check result and
	set errno as appropriate.
	* math/w_scalbf.c (__scalbf): Likewise.
	* math/w_scalbl.c (__scalbl): Likewise.
	* math/gen-libm-test.pl (parse_args): Handle ERRNO_PLUS_OFLOW,
	ERRNO_MINUS_OFLOW, ERRNO_PLUS_UFLOW and ERRNO_MINUS_UFLOW.
	* math/libm-test.inc (scalb_test_data): Add errno expectations.
	Add more NaN tests.
2014-03-31 14:57:53 +00:00
Joseph Myers ea6029b19c Fix scalb spurious "invalid" exceptions (bug 16770).
This patch fixes bug 16770, spurious "invalid" exceptions from scalb
when testing whether the second argument is an integer, by inserting
appropriate range checks to determine whether a cast to int is safe.
(Note that invalid_fn is a function that handles both nonintegers and
large integers, distinguishing them reliably using functions such as
__rint; note also that there are no issues with scalb needing to avoid
spurious "inexact" exceptions - it's an old-POSIX XSI function, not a
standard C function bound to an IEEE 754 operation - although the
return value is still fully determined.)

Tested x86_64 and x86.

	[BZ #16770]
	* math/e_scalb.c (__ieee754_scalb): Check second argument is not
	too large before casting to int.
	* math/e_scalbf.c (__ieee754_scalbf): Likewise.
	* math/e_scalbl.c (__ieee754_scalbl): Likewise.
	* math/libm-test.inc (scalb_test_data): Add more tests.
2014-03-29 17:22:14 +00:00
Joseph Myers 289e077957 Fix clog10 (-0 +/- 0i) (bug 16362).
This patch fixes the imaginary part of clog10 (-0 +/- 0i), which
should be +/-pi / log(10) by analogy with clog (the functions were
wrongly returning a result with imaginary part +/-pi, same as for
clog, and the tests matched the incorrect result, though both
functions and tests were correct for the similar case of clog10 (-inf
+/- 0i)).  Tested x86_64 and x86.

	[BZ #16362]
	* math/s_clog10.c (M_PI_LOG10E): New macro.
	(__clog10): Use M_PI_LOG10E instead of M_PI when real and
	imaginary parts are 0.
	* math/s_clog10f.c (M_PI_LOG10Ef): New macro.
	(__clog10f): Use M_PI_LOG10Ef instead of M_PI when real and
	imaginary parts are 0.
	* math/s_clog10l.c (M_PI_LOG10El): New macro.
	(__clog10l): Use M_PI_LOG10El instead of M_PIl when real and
	imaginary parts are 0.
	* math/libm-test.inc (clog10_test_data): Update expected results
	for when real and imaginary parts are 0.
2014-03-28 20:53:32 +00:00
Joseph Myers 046651c168 Relax gen-auto-libm-tests may-underflow rules, test log1p in all rounding modes.
gen-auto-libm-tests presently allows but does not require underflow
exceptions for results with magnitude in the range (greatest
subnormal, least normal].

In some cases, the magnitude of the exact result is very slightly
above the least normal, but rounding in the implementation results in
it effectively computing an infinite-precision result that is slightly
below the least normal, so raising an underflow exception.  This is in
accordance with the documented accuracy goals, but results in
testsuite failures.

This patch changes the logic to allow underflows when the mathematical
result is up to 0.5ulp above the least normal (so in any case where
the round-to-nearest result is the least normal).  Ideally underflows
in all these cases would be accepted only when an underflow with the
actual result is consistent with the rounding mode (in FE_TOWARDZERO
mode, a return value of the least normal implies that the
infinite-precision result did not underflow so there should be no
underflow exception, for example), so as to match the documented goals
more precisely - whereas at present the tests for exceptions are
completely independent of the tests of the returned values.  (The same
applies to overflow exceptions as well - they too should be checked
for consistency with the result, as in FE_TOWARDZERO mode a result
1ulp below the largest finite value should be inconsistent with an
overflow exception and cause a failure with overflow rather than
simply being considered a 1ulp error when overflow is expected.)  But
the present patch at least deals with the cases causing spurious
failures so that (a) certain existing tests no longer need to be
marked as having spurious exceptions (such markings in
auto-libm-test-in end up applying to more cases than just those they
are needed for) and (b) log1p can be tested in all rounding modes
without introducing more such failures.  This patch duly moves tests
of log1p to ALL_RM_TEST.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16357]
	[BZ #16599]
	* math/gen-auto-libm-tests.c (fp_format_desc): Add field
	min_plus_half.
	(fp_formats): Update initializers.
	(init_fp_formats): Initialize new field.
	(output_for_one_input_case): Allow underflow for results up to
	min_plus_half.
	* math/libm-test.inc (log1p_test): Use ALL_RM_TEST.
	* math/auto-libm-test-in: Don't mark some underflows from asin and
	atanh as spurious.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-25 12:26:06 +00:00
Joseph Myers b376a11a19 Fix dbl-64 exp overflow/underflow in non-default rounding modes (bug 16284).
The dbl-64 version of exp needs round-to-nearest mode for its internal
computations, but that has the consequence of inappropriate
overflowing and underflowing results in other rounding modes.  This
patch fixes this by recomputing the relevant results in cases where
the round-to-nearest result overflows to infinity or underflows to
zero (most of the diffs are actually just consequent reindentation).
Tests are enabled in all rounding modes for complex functions using
exp - but not for cexp because it turns out there are bugs causing
spurious underflows for cexp for some tests, which will need to be
fixed separately (I suspect ccos ccosh csin csinh ctan ctanh have
similar bugs, just not shown by the present set of test inputs).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16284]
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Use original
	rounding mode to recompute results that overflow to infinity or
	underflow to zero.
	* math/auto-libm-test-in: Don't mark tests as expected to fail for
	bug 16284.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (ccos_test): Use ALL_RM_TEST.
	(ccosh_test): Likewise.
	(csin_test_data): Use plus_oflow.
	(csin_test): Use ALL_RM_TEST.
	(csinh_test_data): Use plus_oflow.
	(csinh_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-24 12:18:45 +00:00
Joseph Myers f7be737659 Fix log (1) in round-downward mode (bug 16731).
According to ISO C Annex F, log (1) should be +0 in all rounding
modes, but some implementations in glibc wrongly return -0 in
round-downward mode (mapping to log1p (x - 1) is problematic because 1
- 1 is -0 in round-downward mode, and log1p (-0) is -0).  This patch
fixes this.  (It helps with some implementations of other functions
such as acosh, log2 and log10 that call out to log, but not enough to
enable all-rounding-modes testing for those functions without further
fixes to other implementations of them.)

Tested x86_64 and x86 and ulps updated accordingly, and did spot tests
for mips64 for the ldbl-128 fix, and i586 for the sysdeps/i386/fpu
implementations shadowed by those in sysdeps/i386/i686/fpu.

	[BZ #16731]
	* sysdeps/i386/fpu/e_log.S (__ieee754_log): Take absolute value
	when x - 1 is zero.
	* sysdeps/i386/fpu/e_logf.S (__ieee754_logf): Likewise.
	* sysdeps/i386/fpu/e_logl.S (__ieee754_logl): Likewise.
	* sysdeps/i386/i686/fpu/e_logl.S (__ieee754_logl): Likewise.
	* sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Return +0 when
	argument is 1.
	* sysdeps/ieee754/ldbl-128/e_logl.c (__ieee754_logl): Likewise.
	* sysdeps/x86_64/fpu/e_logl.S: Take absolute value when x - 1 is
	zero.
	* math/libm-test.inc (log_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-21 18:13:58 +00:00
Joseph Myers 8c92dfff41 Test most libm functions in all rounding modes.
This patch makes libm-test.inc tests of most functions use ALL_RM_TEST
unless there was some reason to defer that change for a particular
function.

I started out planning to defer the change for pow (bug 16315), cexp /
ccos / ccosh / csin / csinh (likely fallout from exp, bug 16284) and
cpow (exact expectations for signs of exact zero results not wanted).
Testing on x86_64 and x86 showed additional failures for acosh, cacos,
catan, catanh, clog, clog10, jn, log, log10, log1p, log2, tgamma, yn,
so making the change for those functions was deferred as well, pending
investigation to show which of these represent distinct bugs (some
such bugs may already be filed) and appropriate fixing / XFAILing.
Failures include wrong signs of zero results, errors slightly above
the 9ulp bound (in such cases it may make sense for functions to set
round-to-nearest internally to reduce error accumulation), large
errors and incorrect overflow/underflow for the rounding mode (with
consequent missing errno settings in some cases).  It's possible some
could be issues with test expectations, though I didn't notice any
that were obviously like that (I added NO_TEST_INLINE for cases that
were failing for ildoubl on x86 and where it seemed reasonable for
them to fail for the fast-math inlines).

There may of course be failures on other architectures for functions
that didn't fail on x86_64 or x86, in which case the usual rule
applies: file a bug (preferably identifying the underlying problem
function, in cases where function A calls function B and a problem
with function B may present in the test results for function A) if not
already in Bugzilla then fix or XFAIL.

Tested x86_64 and x86 and ulps updated accordingly.

	* math/libm-test.inc (asinh_test): Use ALL_RM_TEST.
	(atan_test): Likewise.
	(atanh_test_data): Use NO_TEST_INLINE for two tests.
	(atanh_test): Use ALL_RM_TEST.
	(atan2_test_data): Likewise.
	(cabs_test): Likewise.
	(cacosh_test): Likewise.
	(carg_test): Likewise.
	(casin_test): Likewise.
	(casinh_test): Likewise.
	(cbrt_test): Likewise.
	(csqrt_test): Likewise.
	(erf_test): Likewise.
	(erfc_test): Likewise.
	(pow10_test): Likewise.
	(exp2_test): Likewise.
	(hypot_test): Likewise.
	(j0_test): Likewise.
	(j1_test): Likewise.
	(lgamma_test): Likewise.
	(gamma_test): Likewise.
	(sincos_test): Likewise.
	(tanh_test): Likewise.
	(y0_test): Likewise.
	(y1_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-21 00:03:38 +00:00
Joseph Myers ae3a5dff0f Make libm-test support ALL_RM_TEST with AUTO_TESTS_*.
This patch continues improvements to all-rounding-mode libm testing by
making testing with ALL_RM_TEST support test results from
auto-libm-test-out.  gen-libm-test.pl is adapted to generate
appropriate output with results for each rounding mode, with
AUTO_TESTS_* calls no longer specifying a rounding mode.  Where there
were separate functions in libm-test.inc to test a function in each
rounding mode, using AUTO_TESTS_* to list the tests for each rounding
mode, those are converted to using ALL_RM_TEST (so generally this
patch doesn't change the sets of tests run in each rounding mode,
except that in various cases special-case tests given directly in
libm-test.inc were previously run only for round-to-nearest, and now
are run for all rounding modes).

Tested x86_64 and x86.

	* math/gen-libm-test.pl (generate_testfile): Expect only function
	name as argument to AUTO_TESTS_* and pass results for all rounding
	modes to parse_args.
	(parse_auto_input): Separate inputs of automatic tests from
	outputs before storing in %auto_tests.
	* math/libm-test.inc (acos_test_data): Update call to
	AUTO_TESTS_f_f.
	(acos_test): Use ALL_RM_TEST.
	(acos_tonearest_test_data): Remove.
	(acos_test_tonearest): Likewise.
	(acos_towardzero_test_data): Likewise.
	(acos_test_towardzero): Likewise.
	(acos_downward_test_data): Likewise.
	(acos_test_downward): Likewise.
	(acos_upward_test_data): Likewise.
	(acos_test_upward): Likewise.
	(acosh_test_data): Update call to AUTO_TESTS_f_f.
	(asin_test_data): Likewise.
	(asin_test): Use ALL_RM_TEST.
	(asin_tonearest_test_data): Remove.
	(asin_test_tonearest): Likewise.
	(asin_towardzero_test_data): Likewise.
	(asin_test_towardzero): Likewise.
	(asin_downward_test_data): Likewise.
	(asin_test_downward): Likewise.
	(asin_upward_test_data): Likewise.
	(asin_test_upward): Likewise.
	(asinh_test_data): Update call to AUTO_TESTS_f_f.
	(atan_test_data): Likewise.
	(atanh_test_data): Likewise.
	(atan2_test_data): Update call to AUTO_TESTS_ff_f.
	(cabs_test_data): Update call to AUTO_TESTS_c_f.
	(carg_test_data): Likewise.
	(cbrt_test_data): Update call to AUTO_TESTS_f_f.
	(ccos_test_data): Update call to AUTO_TESTS_c_c.
	(ccosh_test_data): Likewise.
	(cexp_test_data): Likewise.
	(clog_test_data): Likewise.
	(clog10_test_data): Likewise.
	(cos_test_data): Update call to AUTO_TESTS_f_f.
	(cos_test): Use ALL_RM_TEST.
	(cos_tonearest_test_data): Remove.
	(cos_test_tonearest): Likewise.
	(cos_towardzero_test_data): Likewise.
	(cos_test_towardzero): Likewise.
	(cos_downward_test_data): Likewise.
	(cos_test_downward): Likewise.
	(cos_upward_test_data): Likewise.
	(cos_test_upward): Likewise.
	(cosh_test_data): Update call to AUTO_TESTS_f_f.
	(cosh_test): Use ALL_RM_TEST.
	(cosh_tonearest_test_data): Remove.
	(cosh_test_tonearest): Likewise.
	(cosh_towardzero_test_data): Likewise.
	(cosh_test_towardzero): Likewise.
	(cosh_downward_test_data): Likewise.
	(cosh_test_downward): Likewise.
	(cosh_upward_test_data): Likewise.
	(cosh_test_upward): Likewise.
	(cpow_test_data): Update call to AUTO_TESTS_cc_c.
	(csqrt_test_data): Update call to AUTO_TESTS_c_c.
	(ctan_test_data): Likewise.
	(ctan_test): Use ALL_RM_TEST.
	(ctan_tonearest_test_data): Remove.
	(ctan_test_tonearest): Likewise.
	(ctan_towardzero_test_data): Likewise.
	(ctan_test_towardzero): Likewise.
	(ctan_downward_test_data): Likewise.
	(ctan_test_downward): Likewise.
	(ctan_upward_test_data): Likewise.
	(ctan_test_upward): Likewise.
	(ctanh_test_data): Update call to AUTO_TESTS_c_c.
	(ctanh_test): Use ALL_RM_TEST.
	(ctanh_tonearest_test_data): Remove.
	(ctanh_test_tonearest): Likewise.
	(ctanh_towardzero_test_data): Likewise.
	(ctanh_test_towardzero): Likewise.
	(ctanh_downward_test_data): Likewise.
	(ctanh_test_downward): Likewise.
	(ctanh_upward_test_data): Likewise.
	(ctanh_test_upward): Likewise.
	(erf_test_data): Update call to AUTO_TESTS_f_f.
	(erfc_test_data): Likewise.
	(exp_test_data): Likewise.
	(exp_test): Use ALL_RM_TEST.
	(exp_tonearest_test_data): Remove.
	(exp_test_tonearest): Likewise.
	(exp_towardzero_test_data): Likewise.
	(exp_test_towardzero): Likewise.
	(exp_downward_test_data): Likewise.
	(exp_test_downward): Likewise.
	(exp_upward_test_data): Likewise.
	(exp_test_upward): Likewise.
	(exp10_test_data): Update call to AUTO_TESTS_f_f.
	(exp10_test): Use ALL_RM_TEST.
	(exp10_tonearest_test_data): Remove.
	(exp10_test_tonearest): Likewise.
	(exp10_towardzero_test_data): Likewise.
	(exp10_test_towardzero): Likewise.
	(exp10_downward_test_data): Likewise.
	(exp10_test_downward): Likewise.
	(exp10_upward_test_data): Likewise.
	(exp10_test_upward): Likewise.
	(exp2_test_data): Update call to AUTO_TESTS_f_f.
	(expm1_test_data): Likewise.
	(expm1_test): Use ALL_RM_TEST.
	(expm1_tonearest_test_data): Remove.
	(expm1_test_tonearest): Likewise.
	(expm1_towardzero_test_data): Likewise.
	(expm1_test_towardzero): Likewise.
	(expm1_downward_test_data): Likewise.
	(expm1_test_downward): Likewise.
	(expm1_upward_test_data): Likewise.
	(expm1_test_upward): Likewise.
	(fma_test_data): Update call to AUTO_TESTS_fff_f.
	(fma_test): Use ALL_RM_TEST.
	(fma_towardzero_test_data): Remove.
	(fma_test_towardzero): Likewise.
	(fma_downward_test_data): Likewise.
	(fma_test_downward): Likewise.
	(fma_upward_test_data): Likewise.
	(fma_test_upward): Likewise.
	(hypot_test_data): Update call to AUTO_TESTS_ff_f.
	(j0_test_data): Update call to AUTO_TESTS_f_f.
	(j1_test_data): Likewise.
	(jn_test_data): Update call to AUTO_TESTS_if_f.
	(lgamma_test_data): Update call to AUTO_TESTS_f_f1.
	(log_test_data): Update call to AUTO_TESTS_f_f.
	(log10_test_data): Likewise.
	(log1p_test_data): Likewise.
	(log2_test_data): Likewise.
	(pow_test_data): Update call to AUTO_TESTS_ff_f.
	(pow_tonearest_test_data): Likewise.
	(sin_test_data): Update call to AUTO_TESTS_f_f.
	(sin_test): Use ALL_RM_TEST.
	(sin_tonearest_test_data): Remove.
	(sin_test_tonearest): Likewise.
	(sin_towardzero_test_data): Likewise.
	(sin_test_towardzero): Likewise.
	(sin_downward_test_data): Likewise.
	(sin_test_downward): Likewise.
	(sin_upward_test_data): Likewise.
	(sin_test_upward): Likewise.
	(sincos_test_data): Update call to AUTO_TESTS_fFF_11.
	(sinh_test_data): Update call to AUTO_TESTS_f_f.
	(sinh_test): Use ALL_RM_TEST.
	(sinh_tonearest_test_data): Remove.
	(sinh_test_tonearest): Likewise.
	(sinh_towardzero_test_data): Likewise.
	(sinh_test_towardzero): Likewise.
	(sinh_downward_test_data): Likewise.
	(sinh_test_downward): Likewise.
	(sinh_upward_test_data): Likewise.
	(sinh_test_upward): Likewise.
	(sqrt_test_data): Update call to AUTO_TESTS_f_f.
	(sqrt_test): Use ALL_RM_TEST.
	(sqrt_tonearest_test_data): Remove.
	(sqrt_test_tonearest): Likewise.
	(sqrt_towardzero_test_data): Likewise.
	(sqrt_test_towardzero): Likewise.
	(sqrt_downward_test_data): Likewise.
	(sqrt_test_downward): Likewise.
	(sqrt_upward_test_data): Likewise.
	(sqrt_test_upward): Likewise.
	(tan_test_data): Update call to AUTO_TESTS_f_f.
	(tan_test): Use ALL_RM_TEST.
	(tan_tonearest_test_data): Remove.
	(tan_test_tonearest): Likewise.
	(tan_towardzero_test_data): Likewise.
	(tan_test_towardzero): Likewise.
	(tan_downward_test_data): Likewise.
	(tan_test_downward): Likewise.
	(tan_upward_test_data): Likewise.
	(tan_test_upward): Likewise.
	(tanh_test_data): Update call to AUTO_TESTS_f_f.
	(tgamma_test_data): Likewise.
	(y0_test_data): Likewise.
	(y1_test_data): Likewise.
	(yn_test_data): Update call to AUTO_TESTS_if_f.
	(main): Do not call removed functions.
2014-03-20 11:48:07 +00:00
Joseph Myers d71aeee886 Use ALL_RM_TEST for more libm tests.
Continuing the move to using ALL_RM_TEST for tests in libm-test.inc,
this patch converts the tests of fdim, ldexp and scalb.  fdim and
scalb are cases where tests could depend on the rounding mode though
none of the present test inputs do; ldexp is such a case where the
function is equivalent to scalbn (for binary floating point) and the
tests used were a subset of those for scalbn, so this patch makes
ldexp testing use the scalbn tests, as done for other cases of libm
function aliases.

Tested x86_64 and x86.

	* math/libm-test.inc (fdim_test): Use ALL_RM_TEST.
	(ldexp_test_data): Remove.
	(ldexp_test): Move to after scalbn_test.  Use ALL_RM_TEST with
	scalbn_test_data.
	(scalb_test): Use ALL_RM_TEST.
2014-03-19 16:17:22 +00:00
Joseph Myers b29b6bb8fe Test scalbn and scalbln in all rounding modes, add more tests of negative arguments.
Continuing the move to systematically testing libm functions in all
rounding modes with ALL_RM_TEST, this patch converts the tests of
scalbn and scalbln to use that macro.

Those tests include cases of underflow and overflow, meaning the
expected results depend on the rounding mode.  For convenience in
writing such tests manually, the patch adds the notation plus_oflow,
minus_oflow, plus_uflow and minus_uflow for overflowing / underflowing
results of each sign appropriate to the rounding mode being used, and
gen-libm-test.pl is made to substitute in the appropriate values.  The
tests of underflow and overflow are extended to include negative
arguments to provide better coverage (otherwise minus_oflow and
minus_uflow wouldn't have been used at all).

(A subsequent patch will make ldexp use the scalbn tests, as those
functions are equivalent for binary floating point.)

Tested x86_64 and x86.

	* math/gen-libm-test.pl (parse_args): Handle plus_oflow,
	minus_oflow, plus_uflow and minus_uflow in expected results.
	* math/libm-test.inc (scalbn_test_data): Add more tests of
	negative arguments.  Use plus_oflow, minus_oflow, plus_uflow and
	minus_uflow.
	(scalbn_test): Use ALL_RM_TEST.
	(scalbln_test_data): Add more tests of negative arguments.  Use
	plus_oflow, minus_oflow, plus_uflow and minus_uflow.
	(scalbln_test): Use ALL_RM_TEST.
2014-03-18 18:47:46 +00:00
Joseph Myers b36208627c Test rint and nearbyint with same inputs, in all rounding modes.
This patch arranges for rint and nearbyint to be tested by
libm-test.inc with the same inputs (previously each had some test
inputs the other didn't, although there was a lot of overlap as well),
and for nearbyint to be tested in all rounding modes where previously
it was only tested in round-to-nearest mode.  The expected results are
the same for each function, except that rint is expected to have
"inexact" exceptions for non-integer input and nearbyint is expected
not to have those exceptions.

Tested x86_64 and x86.

	* math/libm-test.inc (nearbyint_test_data): Include all tests used
	for rint.  Include results for all rounding modes.
	(nearbyint_test): Use ALL_RM_TEST.
	(rint_test_data): Include all tests used for nearbyint.
2014-03-17 21:18:18 +00:00
Joseph Myers 9962a2d34e Add libm-test support for per-rounding-mode manually specified results.
This patch continues the libm-test move towards automatic testing of
all test inputs in all rounding modes by adding gen-libm-test.pl
support for tests specifying results in each rounding mode manually.

Previously a TEST_* line could specify arguments and results, or
arguments, results and flags.  Now there is the option of (arguments,
results-rd, flags-rd, results-rn, flags-rn, results-rz, flags-rz,
results-ru, flags-ru).  This is used to replace the separate arrays of
results in each rounding mode for lrint, llrint and rint.  (In the
case of rint, some tests were only in rint_test_data and needed to
have expectations for non-default rounding modes added, which I did
manually.  In various cases there were slight differences in things
such as the ordering of tests in the arrays for each mode.)

Tested x86_64 and x86.

	* math/gen-libm-test.pl (parse_args): Handle results specified for
	each rounding mode separately.
	* math/libm-test.inc (lrint_test_data): Merge in per-rounding-mode
	tests and results from lrint_tonearest_test_data,
	lrint_towardzero_test_data, lrint_downward_test_data and
	lrint_upward_test_data.
	(lrint_test): Use ALL_RM_TEST.
	(lrint_tonearest_test_data): Remove.
	(lrint_test_tonearest): Likewise.
	(lrint_towardzero_test_data): Likewise.
	(lrint_test_towardzero): Likewise.
	(lrint_downward_test_data): Likewise.
	(lrint_test_downward): Likewise.
	(lrint_upward_test_data): Likewise.
	(lrint_test_upward): Likewise.
	(llrint_test_data): Merge in per-rounding-mode tests and results
	from llrint_tonearest_test_data, llrint_towardzero_test_data,
	llrint_downward_test_data and llrint_upward_test_data.
	(llrint_test): Use ALL_RM_TEST.
	(llrint_tonearest_test_data): Remove.
	(llrint_test_tonearest): Likewise.
	(llrint_towardzero_test_data): Likewise.
	(llrint_test_towardzero): Likewise.
	(llrint_downward_test_data): Likewise.
	(llrint_test_downward): Likewise.
	(llrint_upward_test_data): Likewise.
	(llrint_test_upward): Likewise.
	(rint_test_data): Merge in per-rounding-mode tests and results
	from rint_tonearest_test_data, rint_towardzero_test_data,
	rint_downward_test_data and rint_upward_test_data.  Add
	per-rounding-mode results for tests not in those arrays.
	(rint_test): Use ALL_RM_TEST.
	(rint_tonearest_test_data): Remove.
	(rint_test_tonearest): Likewise.
	(rint_towardzero_test_data): Likewise.
	(rint_test_towardzero): Likewise.
	(rint_downward_test_data): Likewise.
	(rint_test_downward): Likewise.
	(rint_upward_test_data): Likewise.
	(rint_test_upward): Likewise.
	(main): Don't call removed functions.
2014-03-17 12:29:26 +00:00
Adhemerval Zanella c7de502503 PowerPC: remove wrong roundl implementation for PowerPC64
The roundl assembly implementation
(sysdeps/powerpc/powerpc64/fpu/s_roundl.S)
returns wrong results for some inputs where first double is a exact
integer and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_roundl.c instead fixes the failing math.

This fixes 16707.
2014-03-14 12:54:47 -05:00
Adhemerval Zanella 98fb27a373 PowerPC: remove wrong nearbyintl implementation for PPC64
The nearbyintl assembly implementation
(sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S)
returns wrong results for some inputs where first double is a exact
integer and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c instead fixes the failing
math.

Fixes BZ#16706.
2014-03-14 12:54:47 -05:00
Adhemerval Zanella 374f7f6121 PowerPC: remove wrong ceill implementation for PowerPC64
The ceill assembly implementation (sysdeps/powerpc/powerpc64/fpu/s_ceill.S)
returns wrong results for some inputs where first double is a exact
integer and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_ceill.c instead fixes the failing math.

Fixes BZ#16701.
2014-03-14 12:54:47 -05:00
Adhemerval Zanella 4655c291d1 Add truncl tests related to BZ#16414 2014-03-14 12:54:47 -05:00
Joseph Myers 600fa36158 Fix nextafter overflow in non-default rounding modes (bug 16677).
ISO C requires the result of nextafter to be independent of the
rounding mode, even when underflow or overflow occurs.  This patch
fixes the bug in various nextafter implementations that, having done
an overflowing computation to force an overflow exception (correct),
they then return the result of that computation rather than an
infinity computed some other way (incorrect, when the overflowing
result of arithmetic with that sign and rounding mode is finite but
the correct result is infinite) - generally by falling through to
existing code to return a value that in fact is correct for this case
(but was computed by an integer increment and so without generating
the exceptions required).  Having fixed the bug, the previously
deferred conversion of nextafter testing in libm-test.inc to
ALL_RM_TEST is also included.

Tested x86_64 and x86; also spot-checked results of nextafter tests
for powerpc32 and mips64 to test the ldbl-128ibm and ldbl-128
changes.  (The m68k change is untested.)

	[BZ #16677]
	* math/s_nextafter.c (__nextafter): Do not return value from
	overflowing computation.
	* sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* sysdeps/ieee754/flt-32/s_nextafterf.c (__nextafterf): Likewise.
	* sysdeps/ieee754/ldbl-128/s_nextafterl.c (__nextafterl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* math/libm-test.inc (nextafter_test): Use ALL_RM_TEST.
2014-03-11 22:24:00 +00:00
Joseph Myers e9996ef750 Add libm-test.inc macro for all-rounding-modes testing.
This patch adds support in libm-test.inc for automatically running
tests of a function in all rounding modes, in the form of a macro
ALL_RM_TEST to loop over all rounding modes when running tests of a
function, and uses it for functions whose results should always be
independent of the rounding mode.

Conversion of tests of nextafter to ALL_RM_TEST was deferred because
trying that conversion showed up bug 16677.  (Finding such a bug of
course illustrates the point of testing more systematically in all
rounding modes rather than only reactively when bugs get reported in a
particular function in a non-default mode.)  Conversion of tests where
results can depend on the rounding mode will follow once I add
gen-libm-test.pl support for using different initializers for the
expected results for different rounding modes (again, some conversions
may need deferring until bugs are fixed, depending on how
straightforward they are to XFAIL in a particular context).

Some existing tests get run five times rather than four, with
round-to-nearest tests both run in that as default rounding mode and
also with it explicitly set with fesetround (FE_TONEAREST).  This
duplication doesn't seem particularly useful, so ALL_RM_TEST only runs
tests four times.

Tested x86_64 and x86.

	* math/libm-test.inc (ALL_RM_TEST): New macro.
	(ceil_test): Use ALL_RM_TEST.
	(cimag_test): Likewise.
	(conj_test): Likewise.
	(copysign_test): Likewise.
	(cproj_test): Likewise.
	(creal_test): Likewise.
	(fabs_test): Likewise.
	(floor_test): Likewise.
	(fmax_test): Likewise.
	(fmin_test): Likewise.
	(fmod_test): Likewise.
	(fpclassify_test): Likewise.
	(frexp_test): Likewise.
	(ilogb_test): Likewise.
	(isfinite_test): Likewise.
	(finite_test): Likewise.
	(isgreater_test): Likewise.
	(isgreaterequal_test): Likewise.
	(isinf_test): Likewise.
	(isless_test): Likewise.
	(islessequal_test): Likewise.
	(islessgreater_test): Likewise.
	(isnan_test): Likewise.
	(isnormal_test): Likewise.
	(issignaling_test): Likewise.
	(isunordered_test): Likewise.
	(logb_test): Likewise.
	(logb_downward_test_data): Remove.
	(logb_test_downward): Likewise.
	(lround_test): Use ALL_RM_TEST.
	(llround_test): Likewise.
	(modf_test): Likewise.
	(nexttoward_test): Likewise.
	(remainder_test): Likewise.
	(drem_test): Likewise.
	(remainder_tonearest_test_data): Likewise.
	(remainder_test_tonearest): Likewise.
	(drem_test_tonearest): Likewise.
	(remainder_towardzero_test_data): Likewise.
	(remainder_test_towardzero): Likewise.
	(drem_test_towardzero): Likewise.
	(remainder_downward_test_data): Likewise.
	(remainder_test_downward): Likewise.
	(drem_test_downward): Likewise.
	(remainder_upward_test_data): Likewise.
	(remainder_test_upward): Likewise.
	(drem_test_upward): Likewise.
	(remquo_test): Use ALL_RM_TEST.  Remove comment about x.
	(round_test): Use ALL_RM_TEST.
	(signbit_test): Likewise.
	(trunc_test): Likewise.
	(significand_test): Likewise.
	(main): Don't call removed functions.
2014-03-08 14:08:38 +00:00
Joseph Myers 215db4029e Prepare libm-test.inc structures for multi-rounding-mode testing.
At present, libm-test.inc tests are run in multiple rounding modes by
having a separate array for each rounding mode (which might or might
not have the same test inputs as the other such arrays), a separate
function calling a RUN_TEST_LOOP_* macro over that array, and a
separate call to that function in main.  The number of functions
tested in multiple rounding modes has gradually increased as
rounding-mode-specific bugs have been found and fixed in different
functions.

It would be better to be able to use a single macro call, in a single
function, to run tests for a function over all rounding modes, with
this being done for all libm functions except in cases where it's
deferred until some bugs can be fixed because XFAILing all affected
tests would be painful (that's why the full set of pow tests isn't
currently run in all rounding modes).  This patch helps prepare for
that by making the structures storing expected results for tests store
results for all four rounding modes.  After this patch, the results
for all modes are just duplicates, but tests access the appropriate
field in the structure, so helping to pave the way for when the fields
stop being duplicates and multiple rounding modes can be tested from a
single array.  Tests might in future specify a single set of results,
to be used in all rounding modes; separate results for each rounding
mode, specified manually; or use of auto-libm-tests-* to generate
results for each rounding mode.

Tested x86_64.

	* math/libm-test.inc (struct test_f_f_data): Move expected results
	into structure for each rounding mode.
	(struct test_ff_f_data): Likewise.
	(struct test_ff_f_data_nexttoward): Likewise.
	(struct test_fi_f_data): Likewise.
	(struct test_fl_f_data): Likewise.
	(struct test_if_f_data): Likewise.
	(struct test_fff_f_data): Likewise.
	(struct test_c_f_data): Likewise.
	(struct test_f_f1_data): Likewise.
	(struct test_fF_f1_data): Likewise.
	(struct test_ffI_f1_data): Likewise.
	(struct test_c_c_data): Likewise.
	(struct test_cc_c_data): Likewise.
	(struct test_f_i_data): Likewise.
	(struct test_ff_i_data): Likewise.
	(struct test_f_l_data): Likewise.
	(struct test_f_L_data): Likewise.
	(struct test_fFF_11_data): Likewise.
	(RM_): New macro.
	(RM_FE_DOWNWARD): Likewise.
	(RM_FE_TONEAREST): Likewise.
	(RM_FE_TOWARDZERO): Likewise.
	(RM_FE_UPWARD): Likewise.
	(RUN_TEST_LOOP_f_f): Update references to expected results.
	(RUN_TEST_LOOP_2_f): Likewise.
	(RUN_TEST_LOOP_fff_f): Likewise.
	(RUN_TEST_LOOP_c_f): Likewise.
	(RUN_TEST_LOOP_f_f1): Likewise.
	(RUN_TEST_LOOP_fF_f1): Likewise.
	(RUN_TEST_LOOP_fI_f1): Likewise.
	(RUN_TEST_LOOP_ffI_f1): Likewise.
	(RUN_TEST_LOOP_c_c): Likewise.
	(RUN_TEST_LOOP_cc_c): Likewise.
	(RUN_TEST_LOOP_f_i): Likewise.
	(RUN_TEST_LOOP_f_i_tg): Likewise.
	(RUN_TEST_LOOP_ff_i_tg): Likewise.
	(RUN_TEST_LOOP_f_b): Likewise.
	(RUN_TEST_LOOP_f_b_tg): Likewise.
	(RUN_TEST_LOOP_f_l): Likewise.
	(RUN_TEST_LOOP_f_L): Likewise.
	(RUN_TEST_LOOP_fFF_11): Likewise.
	* math/gen-libm-test.pl (parse_args): Output four copies of
	expected results for each test.
2014-03-06 14:15:00 +00:00
Joseph Myers 2f0a0f4427 Automatically check sanity of ulps from libm tests.
This patch makes libm-test.inc apply sanity checks to ulps values
resulting from tests, or found in libm-test-ulps files, to avoid the
need for manual checking/editing of new ulps for cases that are
excessively large or involve functions that should not have any ulps.
For IBM long double, errors must be at most 14ulp (the largest
currently checked-in value), or at most 3ulp (the documented error
bound for division) in the case of exactly-determined functions; for
other formats, the limits are 9ulp (also the largest currently
checked-in value) and 0ulp.  Limits from ulps files are saturated to
those bounds, and regen-ulps will ignore any errors outside those
bounds.  (Thus if, say, you have an architecture-specific problem with
fma, the tests can still be XFAILed in auto-libm-test-in, but errors
outside the permitted range can no longer be listed in
libm-test-ulps.)

Tested x86_64.

	* math/libm-test.inc (max_valid_error): New variable.
	(init_max_error): Take new argument specifying whether function
	results are exactly determined.  Set max_valid_error and bound
	other variables for errors based on this argument.
	(set_max_error): Do not record results above max_valid_error.
	(check_float_internal): Only accept errors of up to 0.5ulps if
	also at most max_valid_error.
	(START): Take new argument EXACT and pass it to init_max_error.
	(acos_test): Update call to START.
	(acos_test_tonearest): Likewise.
	(acos_test_towardzero): Likewise.
	(acos_test_downward): Likewise.
	(acos_test_upward): Likewise.
	(acosh_test): Likewise.
	(asin_test): Likewise.
	(asin_test_tonearest): Likewise.
	(asin_test_towardzero): Likewise.
	(asin_test_downward): Likewise.
	(asin_test_upward): Likewise.
	(asinh_test): Likewise.
	(atan_test): Likewise.
	(atanh_test): Likewise.
	(atan2_test): Likewise.
	(cabs_test): Likewise.
	(cacos_test): Likewise.
	(cacosh_test): Likewise.
	(carg_test): Likewise.
	(casin_test): Likewise.
	(casinh_test): Likewise.
	(catan_test): Likewise.
	(catanh_test): Likewise.
	(cbrt_test): Likewise.
	(ccos_test): Likewise.
	(ccosh_test): Likewise.
	(ceil_test): Likewise.
	(cexp_test): Likewise.
	(cimag_test): Likewise.
	(clog_test): Likewise.
	(clog10_test): Likewise.
	(conj_test): Likewise.
	(copysign_test): Likewise.
	(cos_test): Likewise.
	(cos_test_tonearest): Likewise.
	(cos_test_towardzero): Likewise.
	(cos_test_downward): Likewise.
	(cos_test_upward): Likewise.
	(cosh_test): Likewise.
	(cosh_test_tonearest): Likewise.
	(cosh_test_towardzero): Likewise.
	(cosh_test_downward): Likewise.
	(cosh_test_upward): Likewise.
	(cpow_test): Likewise.
	(cproj_test): Likewise.
	(creal_test): Likewise.
	(csin_test): Likewise.
	(csinh_test): Likewise.
	(csqrt_test): Likewise.
	(ctan_test): Likewise.
	(ctan_test_tonearest): Likewise.
	(ctan_test_towardzero): Likewise.
	(ctan_test_downward): Likewise.
	(ctan_test_upward): Likewise.
	(ctanh_test): Likewise.
	(ctanh_test_tonearest): Likewise.
	(ctanh_test_towardzero): Likewise.
	(ctanh_test_downward): Likewise.
	(ctanh_test_upward): Likewise.
	(erf_test): Likewise.
	(erfc_test): Likewise.
	(exp_test): Likewise.
	(exp_test_tonearest): Likewise.
	(exp_test_towardzero): Likewise.
	(exp_test_downward): Likewise.
	(exp_test_upward): Likewise.
	(exp10_test): Likewise.
	(exp10_test_tonearest): Likewise.
	(exp10_test_towardzero): Likewise.
	(exp10_test_downward): Likewise.
	(exp10_test_upward): Likewise.
	(pow10_test): Likewise.
	(exp2_test): Likewise.
	(expm1_test): Likewise.
	(expm1_test_tonearest): Likewise.
	(expm1_test_towardzero): Likewise.
	(expm1_test_downward): Likewise.
	(expm1_test_upward): Likewise.
	(fabs_test): Likewise.
	(fdim_test): Likewise.
	(floor_test): Likewise.
	(fma_test): Likewise.
	(fma_test_towardzero): Likewise.
	(fma_test_downward): Likewise.
	(fma_test_upward): Likewise.
	(fmax_test): Likewise.
	(fmin_test): Likewise.
	(fmod_test): Likewise.
	(fpclassify_test): Likewise.
	(frexp_test): Likewise.
	(hypot_test): Likewise.
	(ilogb_test): Likewise.
	(isfinite_test): Likewise.
	(finite_test): Likewise.
	(isgreater_test): Likewise.
	(isgreaterequal_test): Likewise.
	(isinf_test): Likewise.
	(isless_test): Likewise.
	(islessequal_test): Likewise.
	(islessgreater_test): Likewise.
	(isnan_test): Likewise.
	(isnormal_test): Likewise.
	(issignaling_test): Likewise.
	(isunordered_test): Likewise.
	(j0_test): Likewise.
	(j1_test): Likewise.
	(jn_test): Likewise.
	(ldexp_test): Likewise.
	(lgamma_test): Likewise.
	(gamma_test): Likewise.
	(lrint_test): Likewise.
	(lrint_test_tonearest): Likewise.
	(lrint_test_towardzero): Likewise.
	(lrint_test_downward): Likewise.
	(lrint_test_upward): Likewise.
	(llrint_test): Likewise.
	(llrint_test_tonearest): Likewise.
	(llrint_test_towardzero): Likewise.
	(llrint_test_downward): Likewise.
	(llrint_test_upward): Likewise.
	(log_test): Likewise.
	(log10_test): Likewise.
	(log1p_test): Likewise.
	(log2_test): Likewise.
	(logb_test): Likewise.
	(logb_test_downward): Likewise.
	(lround_test): Likewise.
	(llround_test): Likewise.
	(modf_test): Likewise.
	(nearbyint_test): Likewise.
	(nextafter_test): Likewise.
	(nexttoward_test): Likewise.
	(pow_test): Likewise.
	(pow_test_tonearest): Likewise.
	(pow_test_towardzero): Likewise.
	(pow_test_downward): Likewise.
	(pow_test_upward): Likewise.
	(remainder_test): Likewise.
	(drem_test): Likewise.
	(remainder_test_tonearest): Likewise.
	(drem_test_tonearest): Likewise.
	(remainder_test_towardzero): Likewise.
	(drem_test_towardzero): Likewise.
	(remainder_test_downward): Likewise.
	(drem_test_downward): Likewise.
	(remainder_test_upward): Likewise.
	(drem_test_upward): Likewise.
	(remquo_test): Likewise.
	(rint_test): Likewise.
	(rint_test_tonearest): Likewise.
	(rint_test_towardzero): Likewise.
	(rint_test_downward): Likewise.
	(rint_test_upward): Likewise.
	(round_test): Likewise.
	(scalb_test): Likewise.
	(scalbn_test): Likewise.
	(scalbln_test): Likewise.
	(signbit_test): Likewise.
	(sin_test): Likewise.
	(sin_test_tonearest): Likewise.
	(sin_test_towardzero): Likewise.
	(sin_test_downward): Likewise.
	(sin_test_upward): Likewise.
	(sincos_test): Likewise.
	(sinh_test): Likewise.
	(sinh_test_tonearest): Likewise.
	(sinh_test_towardzero): Likewise.
	(sinh_test_downward): Likewise.
	(sinh_test_upward): Likewise.
	(sqrt_test): Likewise.
	(sqrt_test_tonearest): Likewise.
	(sqrt_test_towardzero): Likewise.
	(sqrt_test_downward): Likewise.
	(sqrt_test_upward): Likewise.
	(tan_test): Likewise.
	(tan_test_tonearest): Likewise.
	(tan_test_towardzero): Likewise.
	(tan_test_downward): Likewise.
	(tan_test_upward): Likewise.
	(tanh_test): Likewise.
	(tgamma_test): Likewise.
	(trunc_test): Likewise.
	(y0_test): Likewise.
	(y1_test): Likewise.
	(yn_test): Likewise.
	(significand_test): Likewise.
2014-03-05 15:05:20 +00:00
Joseph Myers e6b6a85705 Don't include individual test ulps in libm-test-ulps.
As recently discussed
<https://sourceware.org/ml/libc-alpha/2014-02/msg00670.html>, it
doesn't seem particularly useful for libm-test-ulps files to contain
huge amounts of data on ulps for individual tests; just the global
maximum observed ulps for each function, together with the
verification of exceptions, errno and special results such as
infinities and NaNs for each test, suffices to verify that a
function's behavior on the given test inputs is within the expected
accuracy.  Removing this data reduces source tree churn caused by
updates to these files when libm tests are added, and reduces the
frequency with which testsuite additions actually need libm-test-ulps
changes at all.

Accordingly, this patch removes that data, so that individual tests
get checked against the global bounds for the given function and only
generate an error if those are exceeded.  Tested x86_64 (including
verifying that if an ulps value is artificially reduced, the tests do
indeed fail as they should and "make regen-ulps" generates the
expected changes).

	* math/libm-test.inc (struct ulp_data): Don't refer to ulps for
	individual tests in comment.
	(libm-test-ulps.h): Don't refer to test_ulps in #include comment.
	(prev_max_error): New variable.
	(prev_real_max_error): Likewise.
	(prev_imag_max_error): Likewise.
	(compare_ulp_data): Don't refer to test names in comment.
	(find_test_ulps): Remove function.
	(find_function_ulps): Likewise.
	(find_complex_function_ulps): Likewise.
	(init_max_error): Take function name as argument.  Look up ulps
	for that function.
	(print_ulps): Remove function.
	(print_max_error): Use prev_max_error instead of calling
	find_function_ulps.
	(print_complex_max_error): Use prev_real_max_error and
	prev_imag_max_error instead of calling find_complex_function_ulps.
	(check_float_internal): Take max_ulp parameter instead of calling
	find_test_ulps.  Don't call print_ulps.
	(check_float): Update call to check_float_internal.
	(check_complex): Update calls to check_float_internal.
	(START): Pass argument to init_max_error.
	* math/gen-libm-test.pl (%results): Don't include "kind"
	information.
	(parse_ulps): Don't handle ulps of individual tests.
	(print_ulps_file): Likewise.
	(output_ulps): Likewise.
	* math/README.libm-test: Update.
	* manual/libm-err-tab.pl (parse_ulps): Don't handle ulps of
	individual tests.
	* sysdeps/aarch64/libm-test-ulps: Remove individual test ulps.
	* sysdeps/alpha/fpu/libm-test-ulps: Likewise.
	* sysdeps/arm/libm-test-ulps: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/ia64/fpu/libm-test-ulps: Likewise.
	* sysdeps/m68k/coldfire/fpu/libm-test-ulps: Likewise.
	* sysdeps/m68k/m680x0/fpu/libm-test-ulps: Likewise.
	* sysdeps/microblaze/libm-test-ulps: Likewise.
	* sysdeps/mips/mips32/libm-test-ulps: Likewise.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
	* sysdeps/powerpc/fpu/libm-test-ulps: Likewise.
	* sysdeps/powerpc/nofpu/libm-test-ulps: Likewise.
	* sysdeps/s390/fpu/libm-test-ulps: Likewise.
	* sysdeps/sh/libm-test-ulps: Likewise.
	* sysdeps/sparc/fpu/libm-test-ulps: Likewise.
	* sysdeps/tile/libm-test-ulps: Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.

	* sysdeps/hppa/fpu/libm-test-ulps: Remove individual test ulps.
2014-03-05 15:02:38 +00:00
Joseph Myers 45adef3cf2 Fix libm-test.inc:print_complex_max_error handling of some error cases.
When regenerating ulps incrementally with "make regen-ulps", the
resulting diffs should only increase existing ulps, never decrease
them.  This allows successive uses of "make regen-ulps" on different
hardware or with different compiler configurations to accumulate ulps
that are sufficient for tests to pass in a variety of configurations.

However, sometimes changes that decrease ulps are wrongly generated;
thus, when applying
<https://sourceware.org/ml/libc-alpha/2014-02/msg00605.html> I had to
remove such changes manually.  The problem is
print_complex_max_error.  If the ulps for either the real or the
imaginary part of a function are out of range, this function prints
the maximum ulps seen for both parts, which then replace those
previously in libm-test-ulps.  So if the ulps for one part are bigger
than recorded before, but those for the other part are smaller, the
diffs reduce existing ulps.

This patch fixes the logic so that only increased ulps get printed.

Tested x86_64 ("make math/tests", and "make regen-ulps" in a situation
with ulps manually modified so one part would go up and the other
down, to confirm the changes have the intended effect then).

	* math/libm-test.inc (print_complex_max_error): Check separately
	whether real and imaginary errors are within allowed range and
	pass 0 to print_complex_function_ulps instead of value within
	allowed range.
2014-03-04 14:16:25 +00:00
Joseph Myers 63689d6165 Move tests of clog10 from libm-test.inc to auto-libm-test-in.
This patch moves tests of clog10 to auto-libm-test-in.  Note that this
means gen-auto-libm-tests will now depend on the recent MPC 1.0.2
release which added a fix for a bug that made gen-auto-libm-tests hang
for clog10.  (It still can't conveniently be used for cacos cacosh
casin casinh catan catanh csin csinh because of extreme slowness of
those functions for special cases in MPC; at least some slow cases of
csin / csinh are fixed in MPC trunk, but not in a release.)

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of clog10.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (clog10_test_data): Use AUTO_TESTS_c_c.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-02-19 14:26:29 +00:00
Joseph Myers c6af2d896c Move tests of fma from libm-test.inc to auto-libm-test-in.
This patch moves tests of fma to auto-libm-test-in, adding the
required support to gen-auto-libm-tests.

Because fma can have exact zero results depending on the rounding
mode, results of fma cannot always be determined from a single value
computed in higher precision with a sticky bit.  Thus, this patch adds
support for recomputing results with the original MPFR/MPC function in
the case where an exact zero is involved.  (This also affects some
results for cpow; when we start testing cpow in all rounding modes, I
think it will be most appropriate to make those tests use
IGNORE_ZERO_INF_SIGN, since ISO C does not attempt to determine signs
of zero results, or special caes in general, for cpow, and I think
signs of zero for cpow are beyond the scope of glibc's accuracy
goals.)

Simply treating the existing test inputs for fma like those for other
functions (i.e., as representing the given value rounded up or down to
any of the supported floating-point formats) increases the size of
auto-libm-test-out by about 16MB (i.e., about half the file is fma
test data).  While rounded versions of tests are perfectly reasonable
test inputs for fma, in this case having them seems excessive, so this
patch allows functions to specify in gen-auto-libm-tests that the
given test inputs are only to be interpreted exactly, not as
corresponding to values rounded up and down.  This reduces the size of
the generated test data for fma to a more reasonable 2MB.

A consequence of this patch is that fma is now tested for correct
presence or absence of "inexact" exceptions, where previously this
wasn't tested because I didn't want to try to add that test coverage
manually to all the existing tests.  As far as I know, the existing
fma implementations are already correct in this regard.

This patch provides the first cases where the gen-auto-libm-tests
support for distinguishing before-rounding/after-rounding underflow
actually produces separate entries in auto-libm-test-out (for
functions without exactly determined results, the affected cases are
all considered underflow-optional, so this only affects functions like
fma with exactly determined results).  I didn't see any signs of
problems with this logic in the output.

Tested x86_64 and x86.

	* math/auto-libm-test-in: Add tests of fma.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (fma_test_data): Use AUTO_TESTS_fff_f.
	(fma_towardzero_test_data): Likewise.
	(fma_downward_test_data): Likewise.
	(fma_upward_test_data): Likewise.
	* math/gen-auto-libm-tests.c (rounding_mode_desc): Add field
	mpc_mode.
	(rounding_modes): Add values for new field.
	(func_calc_method): Add value mpfr_fff_f.
	(func_calc_desc): Add mpfr_fff_f union field.
	(test_function): Add field exact_args.
	(FUNC): Add macro argument EXACT_ARGS.
	(FUNC_mpfr_f_f): Update call to FUNC.
	(FUNC_mpfr_f_f): Likewise.
	(FUNC_mpfr_ff_f): Likewise.
	(FUNC_mpfr_if_f): Likewise.
	(FUNC_mpc_c_f): Likewise.
	(FUNC_mpc_c_c): Likewise.
	(test_functions): Add fma.  Update calls to FUNC.
	(handle_input_arg): Add argument exact_args.
	(add_test): Update call to handle_input_arg.
	(calc_generic_results): Add argument mode.  Handle mpfr_fff_f.
	(output_for_one_input_case): Update call to calc_generic_results.
	Recalculate exact zero results in each rounding mode.
2014-02-18 21:48:51 +00:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Joseph Myers 5b0626b9c5 Fix x86 / x86_64 expl / expl10l wild results in directed rounding modes (bug 16356).
This patch fixes bug 16356, bad results from x86 / x86_64 expl /
exp10l in directed rounding modes, the most serious of the bugs shown
up by my patch expanding libm test coverage.  When I fixed bug 16293,
I thought it was only necessary to set round-to-nearest when using
frndint in expm1 functions, because in other cases the cancellation
error from having the resulting fractional part close to 1 or -1 would
not be significant.  However, in expl and exp10l, the way the final
fractional part gets computed (something more complicated than a
simple subtraction, because more precision is needed than you'd get
that way) can result in a value outside the range [-1, 1] when the
argument to frndint was very close to an integer and was rounded the
"wrong" way because of the rounding mode - and the f2xm1 instruction
has undefined results if its argument is outside [-1, 1], so resulting
in the large errors seen.  So this patch removes the USE_AS_EXPM1L
conditionals on the round-to-nearest settings, so all of expl, expm1l
and exp10l now get round-to-nearest used for frndint (meaning the
final fractional part can at most be slightly above 0.5 in
magnitude).  Associated tests of exp and exp10 are added and testing
of exp10 in directed rounding modes enabled.

Tested x86_64 and x86 and ulps updated accordingly.

	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL): Also set
	round-to-nearest for [!USE_AS_EXPM1L].
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL): Likewise.
	* math/auto-libm-test-in: Do not expect cosh tests to fail.  Add
	more tests of exp and exp10.  Expect some exp10 tests to miss
	exceptions or fail in directed rounding modes.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (exp10_tonearest_test_data): New array.
	(exp10_test_tonearest): New function.
	(exp10_towardzero_test_data): New array.
	(exp10_test_towardzero): New function.
	(exp10_downward_test_data): New array.
	(exp10_test_downward): New function.
	(exp10_upward_test_data): New array.
	(exp10_test_upward): New function.
	(main): Call the new functions.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-21 13:07:16 +00:00
Joseph Myers 31e3a40588 Add more libm-test coverage of [a-c]* real functions.
Various libm functions have inadequate test coverage in libm-test.inc
/ auto-libm-test-in - failing to cover all the usual special cases
(infinities, NaNs, zero, large and small finite values, subnormals) as
well as a reasonable range of ordinary inputs and, where appropriate,
inputs close to the thresholds for underflow and overflow.

This patch improves test coverage for real functions [a-c]* (with the
expectation of adding more coverage for other functions later).

Tested x86_64 and x86 and ulps updated accordingly (and eight glibc
bugs and one C11 DR filed for issues found in the process).

	* math/auto-libm-test-in: Add more tests of acos, acosh, asin,
	asinh, atan, atan2, atanh, cbrt, cos and cosh.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (acosh_test_data): Add more tests.
	(atanh_test_data): Likewise.
	(ceil_test_data): Likewise.
	(copysign_test_data): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-20 21:03:39 +00:00
Joseph Myers b7867a3bfb Move tests of cpow from libm-test.inc to auto-libm-test-in.
This patch moves tests of cpow to auto-libm-test-in, adding the
required support to gen-auto-libm-tests.

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of cpow.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (cpow_test_data): Use AUTO_TESTS_cc_c.
	* * math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_cc_c.
	(func_calc_desc): Add mpc_cc_c union field.
	(test_functions): Add cpow.
	(special_fill_2pi): New function.
	(special_real_inputs): Add 2pi.
	(calc_generic_results): Handle mpc_cc_c.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-20 12:35:10 +00:00
Joseph Myers 7fda568229 Move various TEST_c_c tests from libm-test.inc to auto-libm-test-inc.
This patch moves tests of ccos, ccosh, cexp, clog, csqrt, ctan and
ctanh to auto-libm-test-in, adding the required support to
gen-auto-libm-tests.  Other TEST_c_c functions aren't moved for now
(although the relevant table entries are put in gen-auto-libm-tests
for it to know how to handle them): clog10 because of a known MPC bug
causing it to hang for at least some pure imaginary inputs (fixed in
SVN, but I'd rather not rely on unreleased versions of MPFR or MPC
even if relying on very recent releases); the inverse trig and
hyperbolic functions because of known slowness in special cases; and
csin / csinh because of observed slowness that I need to investigate
and report to the MPC maintainers.  Slowness can be bypassed by moving
to incremental generation (only for new / changed tests) rather than
regenerating the whole of auto-libm-test-out every time, but that
needs implementing.  (This patch takes the time for running
gen-auto-libm-tests from about one second to seven, on my system,
which I think is reasonable.  The slow functions would make it take
several minutes at least, which seems unreasonable.)

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of ccos, ccosh, cexp, clog,
	csqrt, ctan and ctanh.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (TEST_COND_x86_64): New macro.
	(TEST_COND_x86): Likewise.
	(ccos_test_data): Use AUTO_TESTS_c_c.
	(ccosh_test_data): Likewise.
	(cexp_test_data): Likewise.
	(clog_test_data): Likewise.
	(csqrt_test_data): Likewise.
	(ctan_test_data): Likewise.
	(ctan_tonearest_test_data): Likewise.
	(ctan_towardzero_test_data): Likewise.
	(ctan_downward_test_data): Likewise.
	(ctan_upward_test_data): Likewise.
	(ctanh_test_data): Likewise.
	(ctanh_tonearest_test_data): Likewise.
	(ctanh_towardzero_test_data): Likewise.
	(ctanh_downward_test_data): Likewise.
	(ctanh_upward_test_data): Likewise.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_c_c.
	(func_calc_desc): Add mpc_c_c union field.
	(FUNC_mpc_c_c): New macro.
	(test_functions): Add cacos, cacosh, casin, casinh, catan, catanh,
	ccos, ccosh, cexp, clog, clog10, csin, csinh, csqrt, ctan and
	ctanh.
	(special_fill_min_subnorm_p120): New function.
	(special_real_inputs): Add min_subnorm_p120.
	(calc_generic_results): Handle mpc_c_c.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-20 12:32:44 +00:00
Joseph Myers 64a17f1add Move tests of cabs and carg from libm-test.inc to auto-libm-test-in.
This patch moves tests of cabs and carg to auto-libm-test-in, adding
the required support to gen-auto-libm-tests.

Tested x86_64 and x86; no ulps updates needed.

	* math/auto-libm-test-in: Add tests of cabs and carg.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (cabs_test_data): Use AUTO_TESTS_c_f.
	(carg_test_data): Likewise.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_c_f.
	(func_calc_desc): Add mpc_c_f union field.
	(test_functions): Add cabs and carg.
	(calc_generic_results): Handle mpc_c_f.
2013-12-19 21:28:30 +00:00
Joseph Myers 6f6fc48226 Move tests of sincos from libm-test.inc to auto-libm-test-in.
This patch moves tests of sincos to auto-libm-test-in, adding the
required support to gen-auto-libm-tests.

Tested x86_64 and x86 and ulps updated accordingly.

(auto-libm-test-out diffs omitted below.)

	* math/auto-libm-test-in: Add tests of sincos.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (sincos_test_data): Use AUTO_TESTS_fFF_11.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpfr_f_11.
	(func_calc_desc): Add mpfr_f_11 union field.
	(test_functions): Add sincos.
	(calc_generic_results): Handle mpfr_f_11.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-19 17:21:01 +00:00
Joseph Myers f88acd39da Fix x86/x86_64 expm1 inaccuracy near 0 in directed rounding modes (bug 16293).
Bug 16293 is inaccuracy of x86/x86_64 versions of expm1, near 0 in
directed rounding modes, that arises from frndint rounding the
exponent to 1 or -1 instead of 0, resulting in large cancellation
error.  This inaccuracy in turn affects other functions such as sinh
that use expm1.  This patch fixes the problem by setting
round-to-nearest mode temporarily around the affected calls to
frndint.  I don't think this is needed for other uses of frndint, such
as in exp itself, as only for expm1 is the cancellation error
significant.

Tested x86_64 and x86 and ulps updated accordingly.

	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]: Set
	round-to-nearest mode when using frndint.
	* sysdeps/i386/fpu/s_expm1.S (__expm1): Likewise.
	* sysdeps/i386/fpu/s_expm1f.S (__expm1f): Likewise.
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]:
	Likewise.
	* math/auto-libm-test-in: Add more tests of expm1.  Do not expect
	sinh test to fail.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (TEST_COND_x86_64): Remove macro.
	(TEST_COND_x86): Likewise.
	(expm1_tonearest_test_data): New array.
	(expm1_test_tonearest): New function.
	(expm1_towardzero_test_data): New array.
	(expm1_test_towardzero): New function.
	(expm1_downward_test_data): New array.
	(expm1_test_downward): New function.
	(expm1_upward_test_data): New array.
	(expm1_test_upward): New function.
	(main): Run the new test functions.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-19 13:36:10 +00:00
Joseph Myers f889953b44 Move tests of jn and yn from libm-test.inc to auto-libm-test-in.
This patch moves tests of jn and yn to auto-libm-test-in, adding the
required support for gen-auto-libm-tests (and adding a missing
assertion there and fixing logic that was broken for functions with
integer arguments).

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of jn and yn.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (jn_test_data): Use AUTO_TESTS_if_f.
	(yn_test_data): Likewise.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpfr_if_f.
	(func_calc_desc): Add mpfr_if_f union field.
	(FUNC_mpfr_if_f): New macro.
	(test_functions): Add jn and yn.
	(calc_generic_results): Assert type of second input for
	mpfr_ff_f.  Handle mpfr_if_f.
	(output_for_one_input_case): Disable all checking for arguments
	fitting floating-point types in case of an integer argument.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-18 17:59:29 +00:00
Joseph Myers ff362e5b93 Move tests of atan2, hypot and pow from libm-test.inc to auto-libm-test-in. 2013-12-16 21:18:07 +00:00
Joseph Myers 9f0be4f8b5 Move tests of lgamma from libm-test.inc to auto-libm-test-in. 2013-12-08 23:56:28 +00:00
Joseph Myers bbf37bdc12 Move TEST_f_f tests for [l-y]* functions from libm-test.inc to auto-libm-test-in. 2013-12-05 13:54:50 +00:00
Joseph Myers 699ff83712 Fix Bessel function error handling (bug 6807, bug 15901). 2013-12-04 14:39:37 +00:00
Joseph Myers d8e2dbe3e3 Move TEST_f_f tests for [e-j]* functions from libm-test.inc to auto-libm-test-in. 2013-12-03 16:22:49 +00:00