about summary refs log tree commit diff
path: root/math/auto-libm-test-out
Commit message (Collapse)AuthorAgeFilesLines
* Fix exp10 spurious underflows (bug 16560).Joseph Myers2014-06-251-0/+666
| | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes spurious underflows from exp10 for arguments near 0 (part of bug 16560; that bug also includes spurious underflows from exp2, which are not fixed by this patch). The problem is underflows in the internal computation converting the exp10 argument to arguments for exp (with extra precision), and the fix is simply to return 1 early for arguments near enough to 0 (just as arguments with large enough magnitude have their own overflow / underflow logic at the start of the function). Tested x86_64 and x86 and ulps updated accordingly; also tested for powerpc32 and mips64 to validate the ldbl-128ibm and ldbl-128 changes. [BZ #16560] * sysdeps/ieee754/dbl-64/e_exp10.c (__ieee754_exp10): Return 1 for arguments close to 0. * sysdeps/ieee754/ldbl-128/e_exp10l.c (__ieee754_exp10l): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_exp10l.c (__ieee754_exp10l): Likewise. * math/auto-libm-test-in: Add more tests of exp10. * math/auto-libm-test-out: Regenerated. * sysdeps/x86_64/fpu/libm-test-ulps: Update.
* Fix x86/x86_64 expm1l spurious underflow exceptions (bug 16539).Joseph Myers2014-06-241-0/+81
| | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes bug 16539, spurious underflow exceptions from x86 / x86-64 expm1l. The problem is that the computation of a base-2 exponent with extra precision involves spurious underflows for arguments that are small but not subnormal, so a check is added to just return the argument in those cases. (If the argument *is* subnormal, underflowing is correct and the existing code will always underflow, so it suffices to keep using the existing code in that case; some expm1 implementations have a bug (bug 16353) with missing underflow exceptions, but I don't think there's such a bug in this particular version.) Tested x86_64 and x86; no ulps updates needed. (auto-libm-test-out diffs omitted below.) [BZ #16539] * sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]: Just return the argument for normal arguments with exponent below -64. * sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]: Likewise. * math/auto-libm-test-in: Add another test of expm1. * math/auto-libm-test-out: Regenerated.
* Fix ldbl-128 erfl spurious underflows (bug 16287).Joseph Myers2014-06-241-0/+294
| | | | | | | | | | | | | | | | | | | | This patch fixes bug 16287, spurious underflows from ldbl-128 erfl arising from it calling erfcl for arguments with absolute value at least 1.0, although for large positive arguments erfcl correctly underflows but erfl shouldn't. The fix is simply to avoid calling erfcl, and just return 1, for arguments above a cut-off large enough that erfl correctly rounds to-nearest as 1 but not so large that erfcl underflows. Tested mips64. Also tested x86_64 and x86 to confirm the new tests (taken from the tests of erfc) don't cause any problems there; no ulps updates needed. [BZ #16287] * sysdeps/ieee754/ldbl-128/s_erfl.c (__erfl): Return 1 without calling __erfcl for arguments at least 16. * math/auto-libm-test-in: Add more tests of erf. * math/auto-libm-test-out: Regenerated.
* Fix cosh spurious underflows from expm1 (bug 16354), inaccurate results near ↵Joseph Myers2014-06-231-316/+416
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 (bug 17061). This patch fixes bug 16354, spurious underflows from cosh when a tiny argument is passed to expm1 and expm1 correctly underflows although the final result of cosh should be 1. As noted in that bug, some cases are latent because of expm1 implementations not raising underflow (bug 16353), but all the implementations are fixed similarly. They already contained checks for tiny arguments, but the checks were too late to avoid underflow from expm1 (although they would avoid underflow from subsequent squaring of the result of expm1); they are moved before the expm1 calls. The thresholds used for considering arguments tiny are not particularly consistent in how they relate to the precision of the floating-point format in question. They are, however, all sufficient to ensure that the round-to-nearest result of cosh is indeed 1 below the threshold (although sometimes they are smaller than necessary). But the previous logic did not return 1, but the previously computed 1 + expm1(abs(x)) value. And the thresholds in the ldbl-128 and ldbl-128ibm code (0x1p-71L - I suspect 0x3f8b was intended in the code instead of 0x3fb8 - and (roughly) 0x1p-55L) are not sufficient for that value to be 1. So by moving the test for tiny arguments, and consequently returning 1 directly now the expm1 value hasn't been computed by that point, this patch also fixes bug 17061, the (large number of ulps) inaccuracy for small arguments in those implementations. Tests for that bug are duly added. Tested x86_64 and x86 and ulps updated accordingly. Also tested for mips64 and powerpc32 to validate the ldbl-128 and ldbl-128ibm changes. [BZ #16354] [BZ #17061] * sysdeps/ieee754/dbl-64/e_cosh.c (__ieee754_cosh): Check for small arguments before calling __expm1. * sysdeps/ieee754/flt-32/e_coshf.c (__ieee754_coshf): Check for small arguments before calling __expm1f. * sysdeps/ieee754/ldbl-128/e_coshl.c (__ieee754_coshl): Check for small arguments before calling __expm1l. * sysdeps/ieee754/ldbl-128ibm/e_coshl.c (__ieee754_coshl): Likewise. * sysdeps/ieee754/ldbl-96/e_coshl.c (__ieee754_coshl): Likewise. * math/auto-libm-test-in: Add more cosh tests. Do not allow spurious underflow for some cosh tests. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update.
* Set errno for y1 overflow (bug 17050).Joseph Myers2014-06-231-0/+1738
| | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes bug 17050, missing errno setting for y1 overflow (for small positive arguments). An appropriate check is added for overflow directly in the __ieee754_y1 implementation, similar to the check present for yn (doing it there rather than in the wrapper also avoids yn needing to repeat the check when called for order 1 or -1 and it uses __ieee754_y1). Tested x86_64 and x86; no ulps update needed. Also tested for mips64 to verify the ldbl-128 fix (the ldbl-128ibm code just #includes the ldbl-128 file). [BZ #17050] * sysdeps/ieee754/dbl-64/e_j1.c: Include <errno.h>. (__ieee754_y1): Set errno if return value overflows. * sysdeps/ieee754/flt-32/e_j1f.c: Include <errno.h>. (__ieee754_y1f): Set errno if return value overflows. * sysdeps/ieee754/ldbl-128/e_j1l.c: Include <errno.h>. (__ieee754_y1l): Set errno if return value overflows. * sysdeps/ieee754/ldbl-96/e_j1l.c: Include <errno.h>. (__ieee754_y1l): Set errno if return value overflows. * math/auto-libm-test-in: Add more tests of y0, y1 and yn. * math/auto-libm-test-out: Regenerated.
* Test cpow in all rounding modes.Joseph Myers2014-06-231-107/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix pow overflow in non-default rounding modes (bug 16315).Joseph Myers2014-06-231-0/+2670
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix log1pl (LDBL_MAX) in FE_UPWARD mode (bug 16564).Joseph Myers2014-05-141-0/+264
| | | | | | | | | | | | | | | | | | | | | | | Bug 16564 is spurious overflow of log1pl (LDBL_MAX) in FE_UPWARD mode, resulting from log1pl adding 1 to its argument (for arguments not close to 0), which overflows in that mode. This patch fixes this by avoiding adding 1 to large arguments (precisely what counts as large depends on the floating-point format). Tested x86_64 and x86, and spot-checked log1pl tests on mips64 and powerpc64. [BZ #16564] * sysdeps/i386/fpu/s_log1pl.S (__log1pl): Do not add 1 to positive arguments with exponent 65 or above. * sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Do not add 1 to arguments 0x1p113L or above. * sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Do not add 1 to arguments 0x1p107L or above. * sysdeps/x86_64/fpu/s_log1pl.S (__log1pl): Do not add 1 to positive arguments with exponent 65 or above. * math/auto-libm-test-in: Add more tests of log1p. * math/auto-libm-test-out: Regenerated.
* Fix erf underflow handling near 0 (bug 16516).Joseph Myers2014-05-141-0/+200
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug 16516 reports spurious underflows from erf (for all floating-point types), when the result is close to underflowing but does not actually underflow. erf (x) is about (2/sqrt(pi))*x for x close to 0, so there are subnormal arguments for which it does not underflow. The various implementations do (x + efx*x) (for efx = 2/sqrt(pi) - 1), for greater accuracy than if just using a single multiplication by an approximation to 2/sqrt(pi) (effectively, this way there are a few more bits in the approximation to 2/sqrt(pi)). This can introduce underflows when efx*x underflows even though the final result does not, so a scaled calculation with 8*efx is done in these cases - but 8 is not a big enough scale factor to avoid all such underflows. 16 is (any underflows with a scale factor of 16 would only occur when the final result underflows), so this patch changes the code to use that factor. Rather than recomputing all the values of the efx8 variable, it is removed, leaving it to the compiler's constant folding to compute 16*efx. As such scaling can also lose underflows when the final scaling down happens to be exact, appropriate checks are added to ensure underflow exceptions occur when required in such cases. Tested x86_64 and x86; no ulps updates needed. Also spot-checked for powerpc32 and mips64 to verify the changes to the ldbl-128ibm and ldbl-128 implementations. [BZ #16516] * sysdeps/ieee754/dbl-64/s_erf.c (efx8): Remove variable. (__erf): Scale by 16 instead of 8 in potentially underflowing case. Ensure exception if result actually underflows. * sysdeps/ieee754/flt-32/s_erff.c (efx8): Remove variable. (__erff): Scale by 16 instead of 8 in potentially underflowing case. Ensure exception if result actually underflows. * sysdeps/ieee754/ldbl-128/s_erfl.c: Include <float.h>. (efx8): Remove variable. (__erfl): Scale by 16 instead of 8 in potentially underflowing case. Ensure exception if result actually underflows. * sysdeps/ieee754/ldbl-128ibm/s_erfl.c: Include <float.h>. (efx8): Remove variable. (__erfl): Scale by 16 instead of 8 in potentially underflowing case. Ensure exception if result actually underflows. * sysdeps/ieee754/ldbl-96/s_erfl.c: Include <float.h>. (efx8): Remove variable. (__erfl): Scale by 16 instead of 8 in potentially underflowing case. Ensure exception if result actually underflows. * math/auto-libm-test-in: Add more tests of erf. * math/auto-libm-test-out: Regenerated.
* Set errno for atan2 underflow (bug 16349).Joseph Myers2014-03-311-538/+538
| | | | | | | | | | | | | | | | | | | | | | | This patch fixes bug 16349, missing errno setting for atan2 underflow, by adding appropriate checks to the existing wrappers. (As in other cases, the __kernel_standard support for calling matherr is considered to be for existing code expecting existing rules for what's considered an error, even if those don't correspond to a general logical scheme for what counts as what kind of error, so __set_errno calls are added directly without any changes to __kernel_standard.) Tested x86_64 and x86. [BZ #16349] * math/w_atan2.c: Include <errno.h>. (__atan2): Set errno for result underflowing to zero. * math/w_atan2f.c: Include <errno.h>. (__atan2f): Set errno for result underflowing to zero. * math/w_atan2l.c: Include <errno.h>. (__atan2l): Set errno for result underflowing to zero. * math/auto-libm-test-in: Don't allow missing errno for some atan2 tests. * math/auto-libm-test-out: Regenerated.
* Fix x86/x86_64 expl/exp10l spurious underflows (bug 16348).Joseph Myers2014-03-271-0/+666
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes bug 16348, spurious underflows from x86/x86_64 expl on arguments close to 0. These implementations effectively use expm1 (on the fractional part of the argument) internally, so resulting in spurious underflows when the result is very close to 1. For arguments small enough that the round-to-nearest correct result is 1, this patch uses 1+x instead. These implementations are also used for exp10l and so the patch fixes similar issues there (the 0x1p-67 threshold being small enough to be correct for exp10l as well as expl). But because of spurious underflows in other exp10 implementations (bug 16560), the tests aren't added for exp10 at this point - they can be added when the other exp10 parts of that bug are fixed. Tested x86_64 and x86; no ulps updates needed. [BZ #16348] * sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [!USE_AS_EXPM1L]: Use 1+x for argument with exponent below -67. * sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [!USE_AS_EXPM1L]: Likewise. * math/auto-libm-test-in: Add more tests of exp. * math/auto-libm-test-out: Regenerated.
* Relax gen-auto-libm-tests may-underflow rules, test log1p in all rounding modes.Joseph Myers2014-03-251-279/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix dbl-64 exp overflow/underflow in non-default rounding modes (bug 16284).Joseph Myers2014-03-241-376/+376
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Adjust how gen-auto-libm-tests handles before-rounding/after-rounding cases.Joseph Myers2014-03-061-96/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes gen-auto-libm-tests so that, when generating test results that depend on whether the architecture has before-rounding or after-rounding tininess detection, the :before-rounding or :after-rounding conditions go on the exception / errno flags generated, rather than generating two separate lines in auto-libm-test-out for e.g. flt-32:before-rounding and flt-32:after-rounding. The rationale for this is as follows. It would be desirable for testing a libm function in all rounding modes to require just one function and array in libm-test.inc, not four (or five), with the array of test data including expected results for all rounding modes rather than separate arrays for each rounding mode that also need to repeat all the test inputs. For gen-libm-test.pl to generate data for such an array from auto-libm-test-out, it would be helpful if each (format, test input) pair has exactly four lines in auto-libm-test-out, one for each rounding mode, rather than some rounding modes having just one line and some having two because the exceptions depend on tininess detection. Tested x86_64 and x86. * math/gen-auto-libm-tests.c: Update comment on output format. (output_for_one_input_case): Generate before-rounding and after-rounding information as conditions on output flags not floating-point format. * math/auto-libm-test-out: Regenerated. * math/gen-libm-test.pl (cond_value): New function. (or_cond_value): Use cond_value. (generate_testfile): Handle conditional exceptions.
* Fix sign of input to bsloww1 (BZ #16623)Siddhesh Poyarekar2014-02-271-0/+138
| | | | | | | | In 84ba214c, I removed some redundant sign computations and in the process, I incorrectly got rid of a temporary variable, thus passing the absolute value of the input to bsloww1. This caused #16623. This fix undoes the incorrect change.
* Move tests of clog10 from libm-test.inc to auto-libm-test-in.Joseph Myers2014-02-191-0/+27148
| | | | | | | | | | | | | | | | | | 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.
* Move tests of fma from libm-test.inc to auto-libm-test-in.Joseph Myers2014-02-181-12/+15069
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix gen-auto-libm-tests sticky bit setting for negative results.Joseph Myers2014-02-181-4336/+4336
| | | | | | | | | | | | | | | | | | | | | | | | | | | gen-auto-libm-tests has a bug in the logic for setting a sticky bit based on the ternary value from MPFR: it is correct for positive results, but for negative results mpz_setbit acts as if a two's complement representation is used, whereas the low bit needs setting based on the sign-magnitude representation GMP actually uses. (This showed up in converting fma tests to use auto-libm-test-in / gen-auto-libm-tests.) This patch fixes the problem by negating the mpz_t value to set its low bit. There are lots of changes to auto-libm-test-out (mainly 1ulp fixes to ldbl-128 expected results), but only a few ulps updates are needed on x86 / x86_64. In one case, a corrected expectation showed up a spurious underflow exception where the correct result is slightly outside the underflowing range. Tested x86_64 and x86 and ulps updated accordingly. * math/gen-auto-libm-tests.c (adjust_real): Ensure integers are non-negative before setting low bit. * math/auto-libm-test-in: Mark one asin test possibly having spurious underflow. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
* BZ #16447: Fix ldbl-128 expl implementation.Andreas Krebbel2014-02-111-0/+25
| | | | | Extend the range of numbers handled via unsafe mode. Add expl testcase and regenerate ULPs for s390.
* Mark more libm tests with xfail-rounding:ldbl-128ibm.Joseph Myers2014-01-071-416/+416
| | | | | | | | | | | | | | | | | | | | | | | This patch marks more libm tests as expected to fail for ldbl-128ibm in non-default rounding modes. Given this, my expm1l fix <https://sourceware.org/ml/libc-alpha/2014-01/msg00135.html> and my libgcc fix <http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00157.html> for spurious overflows, the remaining failures in test-ldouble.out (for powerpc32 hard float) are small ulps, spurious underflow and inexact exceptions (the former probably arising from libgcc bugs though I haven't checked each case; the latter are barely meaningful for this format anyway when basic arithmetic isn't correctly rounding, though most of them are probably GCC bug 59412 which doesn't actually involve long double), missing underflow exceptions from clog, ctan and ctanh (probably one of the known bugs for another function), and logb in round-downward mode (bug 887, though it's really a GCC bug that we're not currently working around). Tested for powerpc32 hard float. * math/auto-libm-test-in: Mark various tests with xfail-rounding:ldbl-128ibm. * math/auto-libm-test-out: Regenerated.
* Mark various libm tests with xfail-rounding:ldbl-128ibm.Joseph Myers2014-01-031-1718/+1718
| | | | | | | | | | | | | | | | | | | | This patch marks various libm tests with xfail-rounding:ldbl-128ibm, where the failures appear to relate to GCC bug 59666 (bad libgcc handling of directed rounding), so as to allow clean libm-test-ulps regeneration without needing to edit out large ulps for various functions manually. Note that this only deals with the cases problematic for ulps regeneration. There are plenty of test failures left that do not affect ulps regeneration - results that are infinities or NaNs but should be finite, or vice versa, and missing and spurious exceptions - which should also be resolved during the release testing period. Tested for powerpc32 (hard float). * math/auto-libm-test-in: Mark various tests with xfail-rounding:ldbl-128ibm. * math/auto-libm-test-out: Regenerated.
* Fix x86 / x86_64 expl / expl10l wild results in directed rounding modes (bug ↵Joseph Myers2013-12-211-522/+732
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add more libm-test coverage of [a-c]* real functions.Joseph Myers2013-12-201-0/+12536
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Move tests of cpow from libm-test.inc to auto-libm-test-in.Joseph Myers2013-12-201-0/+1200
| | | | | | | | | | | | | | | | | | | | 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.
* Move various TEST_c_c tests from libm-test.inc to auto-libm-test-inc.Joseph Myers2013-12-201-0/+38704
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Move tests of cabs and carg from libm-test.inc to auto-libm-test-in.Joseph Myers2013-12-191-0/+600
| | | | | | | | | | | | | | | | | 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.
* Move tests of sincos from libm-test.inc to auto-libm-test-in.Joseph Myers2013-12-191-0/+1034
| | | | | | | | | | | | | | | | | | | | 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.
* Fix x86/x86_64 expm1 inaccuracy near 0 in directed rounding modes (bug 16293).Joseph Myers2013-12-191-25/+425
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Move tests of jn and yn from libm-test.inc to auto-libm-test-in.Joseph Myers2013-12-181-0/+3069
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Mark some hypot tests no-test-inline.Joseph Myers2013-12-181-631/+631
| | | | | | | As needed on x86. * math/auto-libm-test-in: Mark some hypot tests no-test-inline. * math/auto-libm-test-out: Regenerated.
* Fix ldbl-128 logl for subnormals (bug 16338).Joseph Myers2013-12-181-0/+790
| | | | | | | | | | | | | | | | | | | | | | This patch fixes bug 16338, ldbl-128 logl not handling subnormals (with consequent inaccuracy for lgammal as well). The fix is simply to use __frexpl when determining the exponent, as done already in log2l and log10l. Given the lack of testing of small arguments to any of the log* functions, appropriate tests are added for all of them. Tested x86_64 and x86 and ulps updated accordingly, and spot tests also run for mips64 to confirm the ldbl-128 fix. Note that while this fixes lgammal inaccuracy for small positive arguments, I suspect that there will still be problems with spurious underflows in that case. * sysdeps/ieee754/ldbl-128/e_logl.c (__ieee754_logl): Use __frexpl to determine exponent and adjust argument to have exponent of -1. * math/auto-libm-test-in: Add more tests of log, log10, log1p and log2. * math/auto-libm-test-out: Regenerated. * sysdeps/x86_64/fpu/libm-test-ulps: Update.
* Fix dbl-64 hypot spurious underflows (bug 16314).Joseph Myers2013-12-171-749/+749
|
* Fix hypot handling of subnormals (bug 16316, bug 16330).Joseph Myers2013-12-171-678/+1853
|
* Move tests of atan2, hypot and pow from libm-test.inc to auto-libm-test-in.Joseph Myers2013-12-161-0/+42584
|
* Move tests of lgamma from libm-test.inc to auto-libm-test-in.Joseph Myers2013-12-081-0/+2203
|
* Fix tgamma errno setting on underflow (bug 6810).Joseph Myers2013-12-051-2456/+2506
|
* Move TEST_f_f tests for [l-y]* functions from libm-test.inc to ↵Joseph Myers2013-12-051-0/+32700
| | | | auto-libm-test-in.
* Fix exp missing underflows (bug 15268, bug 15425).Joseph Myers2013-12-031-0/+214
|
* Fix exp2 errno setting on underflow (bug 16283).Joseph Myers2013-12-031-85/+85
|
* Fix erfc errno setting on underflow (bug 6786).Joseph Myers2013-12-031-4/+298
|
* Move TEST_f_f tests for [e-j]* functions from libm-test.inc to ↵Joseph Myers2013-12-031-0/+4141
| | | | auto-libm-test-in.
* Move TEST_f_f tests for [a-c]* functions from libm-test.inc to ↵Joseph Myers2013-11-301-0/+4533
| | | | auto-libm-test-in.
* Fix x86 sqrt rounding (bug 14032).Joseph Myers2013-11-291-0/+3669
|
* Start generating libm tests automatically with MPFR.Joseph Myers2013-11-291-0/+225