aboutsummaryrefslogtreecommitdiff
path: root/math
AgeCommit message (Collapse)AuthorFilesLines
2014-02-10Use glibc_likely instead __builtin_expect.Ondřej Bílka43-125/+125
2014-01-27Let gen-libm-test.pl find itself when run outside source directoryAndreas Schwab1-2/+3
2014-01-16Fix math/test-fpucw-*.c for sysdeps test-fpucw.c overrides.Joseph Myers2-2/+2
ARM has an override of the test math/test-fpucw.c, to disable (for soft-float testing) definitions of hard-float macros in fpu_control.h that the header normally defines not only when building for hard-float, but also when building for soft-float with _LIBC defined so that libc code can dynamically test whether VFP hardware is present. (_LIBC is defined when building tests, although ideally it wouldn't be.) The override doesn't work for the derived tests test-fpucw-*.c because they use #include "" instead of <> to include test-fpucw.c, so always get the math/ version instead of the ARM sysdeps override. This patch changes them to use <> so the sysdeps override is effective. (test-fpucw-ieee-static.c doesn't need a change because it includes test-fpucw-ieee.c, which isn't itself being overridden, which in turn includes test-fpucw.c with a #include changed by this patch.) Tested for ARM (big-endian soft-float, non-VFP hardware). * math/test-fpucw-ieee.c: Use <> in #include of test-fpucw.c. * math/test-fpucw-static.c: Likewise.
2014-01-07Mark more libm tests with xfail-rounding:ldbl-128ibm.Joseph Myers2-433/+439
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.
2014-01-03Mark various libm tests with xfail-rounding:ldbl-128ibm.Joseph Myers2-1744/+1753
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.
2014-01-01Update copyright notices with scripts/update-copyrightsAllan McRae200-200/+200
2013-12-21Fix x86 / x86_64 expl / expl10l wild results in directed rounding modes (bug ↵Joseph Myers3-532/+809
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-20Add more libm-test coverage of [a-c]* real functions.Joseph Myers3-0/+12687
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-20Move tests of cpow from libm-test.inc to auto-libm-test-in.Joseph Myers4-22/+1270
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-20Move various TEST_c_c tests from libm-test.inc to auto-libm-test-inc.Joseph Myers4-508/+39121
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-19Move tests of cabs and carg from libm-test.inc to auto-libm-test-in.Joseph Myers4-48/+666
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-19Move tests of sincos from libm-test.inc to auto-libm-test-in.Joseph Myers4-54/+1074
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-19Disable libm-test test name beautification for M_* constants.Joseph Myers1-17/+0
math/gen-libm-test.pl has code to beautify names of various constants, transforming the source form in libm-test.inc into the version appearing in test names in libm-test-ulps files. This has become decreasingly relevant over time for the M_* constants, first as I changed the test names so only the arguments and not the expected results appeared in them, then as tests have moved to auto-libm-test-* so that automatically generated hex float constants get used instead of M_* in test inputs. This patch removes the beautification for all M_* constants. Tested x86_64 and x86 and ulps updated accordingly. Even the one case where this affected the name in the ulps files will disappear once complex function tests are moved to auto-libm-test-*. * math/gen-libm-test.pl (%beautify): Remove M_* constants. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-19Fix x86/x86_64 expm1 inaccuracy near 0 in directed rounding modes (bug 16293).Joseph Myers3-39/+502
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-18Move tests of jn and yn from libm-test.inc to auto-libm-test-in.Joseph Myers4-104/+3201
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-18Mark some hypot tests no-test-inline.Joseph Myers2-634/+634
As needed on x86. * math/auto-libm-test-in: Mark some hypot tests no-test-inline. * math/auto-libm-test-out: Regenerated.
2013-12-18Fix ldbl-128 logl for subnormals (bug 16338).Joseph Myers2-0/+801
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.
2013-12-17Fix dbl-64 hypot spurious underflows (bug 16314).Joseph Myers2-751/+750
2013-12-17Fix hypot handling of subnormals (bug 16316, bug 16330).Joseph Myers2-681/+1866
2013-12-16Move tests of atan2, hypot and pow from libm-test.inc to auto-libm-test-in.Joseph Myers4-510/+43000
2013-12-08Move tests of lgamma from libm-test.inc to auto-libm-test-in.Joseph Myers4-71/+2293
2013-12-05Fix tgamma errno setting on underflow (bug 6810).Joseph Myers5-2608/+2664
2013-12-05Move TEST_f_f tests for [l-y]* functions from libm-test.inc to ↵Joseph Myers4-809/+33381
auto-libm-test-in.
2013-12-04Fix Bessel function error handling (bug 6807, bug 15901).Joseph Myers9-27/+95
2013-12-03Fix exp missing underflows (bug 15268, bug 15425).Joseph Myers2-0/+216
2013-12-03Fix exp2 errno setting on underflow (bug 16283).Joseph Myers5-96/+92
2013-12-03Fix erfc errno setting on underflow (bug 6786).Joseph Myers2-6/+309
2013-12-03Move TEST_f_f tests for [e-j]* functions from libm-test.inc to ↵Joseph Myers4-211/+4325
auto-libm-test-in.
2013-11-30Move TEST_f_f tests for [a-c]* functions from libm-test.inc to ↵Joseph Myers4-252/+4818
auto-libm-test-in.
2013-11-29Fix exp10 errno setting on underflow (bug 6787).Joseph Myers4-5/+7
2013-11-29Fix x86 sqrt rounding (bug 14032).Joseph Myers2-0/+3726
2013-11-29Test sqrt in all rounding modes.Joseph Myers1-0/+88
2013-11-29Start generating libm tests automatically with MPFR.Joseph Myers6-19/+2110
2013-11-28Fix dbl-64 e_sqrt.c for non-default rounding modes (bug 16271).Joseph Myers1-0/+1
2013-11-19Make powerpc-nofpu floating-point state thread-local (bug 15483).Joseph Myers2-1/+210
2013-11-18test-fpucw-ieee: Don't use _FPU_IEEE if not definedChris Metcalf1-2/+5
Not all architectures define this value, and if they don't, just let the test run the same as test-fpucw, with __fpu_control set to _FPU_DEFAULT explicitly.
2013-11-16Test signs of NaNs in libm-test.inc where appropriate.Joseph Myers2-16/+43
2013-11-16Add libm-test support for ignored return value, add more lrint / llrint / ↵Joseph Myers2-12/+90
lround / llround tests.
2013-11-16Replace libm-test.inc TEST_INLINE conditionals with NO_TEST_INLINE flag.Joseph Myers2-258/+280
2013-11-16Make libm-test.inc check for "inexact" exceptions for NaN argument.Joseph Myers1-69/+69
2013-10-04PowerPC floating point little-endian [4 of 15]Alan Modra1-0/+19
http://sourceware.org/ml/libc-alpha/2013-08/msg00084.html Another batch of ieee854 macros and union replacement. These four files also have bugs fixed with this patch. The fact that the two doubles in an IBM long double may have different signs means that negation and absolute value operations can't just twiddle one sign bit as you can with ieee864 style extended double. fmodl, remainderl, erfl and erfcl all had errors of this type. erfl also returned +1 for large magnitude negative input where it should return -1. The hypotl error is innocuous since the value adjusted twice is only used as a flag. The e_hypotl.c tests for large "a" and small "b" are mutually exclusive because we've already exited when x/y > 2**120. That allows some further small simplifications. [BZ #15734], [BZ #15735] * sysdeps/ieee754/ldbl-128ibm/e_fmodl.c (__ieee754_fmodl): Rewrite all uses of ieee875 long double macros and unions. Simplify test for 0.0L. Correct |x|<|y| and |x|=|y| test. Use ldbl_extract_mantissa value for ix,iy exponents. Properly normalize after ldbl_extract_mantissa, and don't add hidden bit already handled. Don't treat low word of ieee854 mantissa like low word of IBM long double and mask off bit when testing for zero. * sysdeps/ieee754/ldbl-128ibm/e_hypotl.c (__ieee754_hypotl): Rewrite all uses of ieee875 long double macros and unions. Simplify tests for 0.0L and inf. Correct double adjustment of k. Delete dead code adjusting ha,hb. Simplify code setting kld. Delete two600 and two1022, instead use their values. Recognise that tests for large "a" and small "b" are mutually exclusive. Rename vars. Comment. * sysdeps/ieee754/ldbl-128ibm/e_remainderl.c (__ieee754_remainderl): Rewrite all uses of ieee875 long double macros and unions. Simplify test for 0.0L and nan. Correct negation. * sysdeps/ieee754/ldbl-128ibm/s_erfl.c (__erfl): Rewrite all uses of ieee875 long double macros and unions. Correct output for large magnitude x. Correct absolute value calculation. (__erfcl): Likewise. * math/libm-test.inc: Add tests for errors discovered in IBM long double versions of fmodl, remainderl, erfl and erfcl.
2013-10-04PowerPC floating point little-endian [1 of 15]Alan Modra1-214/+75
http://sourceware.org/ml/libc-alpha/2013-08/msg00081.html This is the first of a series of patches to ban ieee854_long_double and the ieee854_long_double macros when using IBM long double. union ieee854_long_double just isn't correct for IBM long double, especially when little-endian, and pretending it is OK has allowed a number of bugs to remain undetected in sysdeps/ieee754/ldbl-128ibm/. This changes the few places in generic code that use it. * stdio-common/printf_size.c (__printf_size): Don't use union ieee854_long_double in fpnum union. * stdio-common/printf_fphex.c (__printf_fphex): Likewise. Use signbit macro to retrieve sign from long double. * stdio-common/printf_fp.c (___printf_fp): Use signbit macro to retrieve sign from long double. * sysdeps/ieee754/ldbl-128ibm/printf_fphex.c: Adjust for fpnum change. * sysdeps/ieee754/ldbl-128/printf_fphex.c: Likewise. * sysdeps/ieee754/ldbl-96/printf_fphex.c: Likewise. * sysdeps/x86_64/fpu/printf_fphex.c: Likewise. * math/test-misc.c (main): Don't use union ieee854_long_double. ports/ * sysdeps/ia64/fpu/printf_fphex.c: Adjust for fpnum change.
2013-09-19New test cases for sin and cos for multiple precision fallbackSiddhesh Poyarekar1-0/+18
2013-09-09Fix static-binary lazy FPU context allocationMaciej W. Rozycki5-7/+40
Long ago static startup did not parse the auxiliary vector and therefore could not get at any `AT_FPUCW' tag to check whether upon FPU context allocation the kernel would use a FPU control word setting different to that provided by the `__fpu_control' variable. Static startup therefore always initialized the FPU control word, forcing immediate FPU context allocation even for binaries that otherwise never used the FPU. As from GIT commit f8f900ecb9096ec47f5b7bb7626e29223c69061a static startup supports parsing the auxiliary vector, so now it can avoid explicit initialization of the FPU control word, just as can dynamic startup, in the usual case where the setting written to the FPU control word would be the same as the kernel uses. This defers FPU context allocation until the binary itself actually pokes at the FPU. Note that the `AT_FPUCW' tag is usually absent from the auxiliary vector in which case _FPU_DEFAULT is assumed to be the kernel default.
2013-09-03Fix lgammaf spurious underflow (bug 15427).Joseph Myers1-0/+55
2013-09-02Fix spurious jnf underflows (bug 14155).Joseph Myers1-2/+17
2013-08-29math: Additional type conversion testsThomas Schwinge1-7/+13
These have helped me find and fix type conversion issues in QEMU's MIPS hardware emulation. While certainly glibc is not the best place for such tests, they're just an enhancement of tests already present.
2013-08-23Fix cexp (NaN + i0) (bug 15532).Joseph Myers4-13/+32
2013-08-21Fix fdim handling of infinities (bug 15797).Joseph Myers4-39/+43
2013-08-20Fix cproj handling of (finite, NaN) arguments (bug 15531).Joseph Myers4-9/+43