about summary refs log tree commit diff
path: root/math
Commit message (Collapse)AuthorAgeFilesLines
* Add nextup and nextdown math functionsRajalakshmi Srinivasaraghavan2016-06-169-7/+253
| | | | | | | | | | | TS 18661 adds nextup and nextdown functions alongside nextafter to provide support for float128 equivalent to it. This patch adds nextupl, nextup, nextupf, nextdownl, nextdown and nextdownf to libm before float128 support. The nextup functions return the next representable value in the direction of positive infinity and the nextdown functions return the next representable value in the direction of negative infinity. These are currently enabled as GNU extensions.
* Fix i386 fdim double rounding (bug 20255).Joseph Myers2016-06-141-0/+3
| | | | | | | | | | | | | | | | | | | fdim suffers from double rounding on i386 because subtracting two double values can produce an inexact long double value exactly half way between two double values. This patch fixes this by creating an i386-specific version of fdim - C, based on the generic version, unlike the previous .S version - which sets the x87 precision control to double precision for the subtraction and then restores it afterwards. As noted in the comment added, there are no issues of double rounding for subnormals (a case that setting precision control does not address) because subtraction cannot produce an inexact result in the subnormal range. Tested for x86_64 and x86. [BZ #20255] * sysdeps/i386/fpu/s_fdim.c: New file. Based on math/s_fdim.c. * math/libm-test.inc (fdim_test_data): Add another test.
* Use generic fdim on more architectures (bug 6796, bug 20255, bug 20256).Joseph Myers2016-06-143-4/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some architectures have their own versions of fdim functions, which are missing errno setting (bug 6796) and may also return sNaN instead of qNaN for sNaN input, in the case of the x86 / x86_64 long double versions (bug 20256). These versions are not actually doing anything that a compiler couldn't generate, just straightforward comparisons / arithmetic (and, in the x86 / x86_64 case, testing for NaNs with fxam, which isn't actually needed once you use an unordered comparison and let the NaNs pass through the same subtraction as non-NaN inputs). This patch removes the x86 / x86_64 / powerpc versions, so that those architectures use the generic C versions, which correctly handle setting errno and deal properly with sNaN inputs. This seems better than dealing with setting errno in lots of .S versions. The i386 versions also return results with excess range and precision, which is not appropriate for a function exactly defined by reference to IEEE operations. For errno setting to work correctly on overflow, it's necessary to remove excess range with math_narrow_eval, which this patch duly does in the float and double versions so that the tests can reliably pass on x86. For float, this avoids any double rounding issues as the long double precision is more than twice that of float. For double, double rounding issues will need to be addressed separately, so this patch does not fully fix bug 20255. Tested for x86_64, x86 and powerpc. [BZ #6796] [BZ #20255] [BZ #20256] * math/s_fdim.c: Include <math_private.h>. (__fdim): Use math_narrow_eval on result. * math/s_fdimf.c: Include <math_private.h>. (__fdimf): Use math_narrow_eval on result. * sysdeps/i386/fpu/s_fdim.S: Remove file. * sysdeps/i386/fpu/s_fdimf.S: Likewise. * sysdeps/i386/fpu/s_fdiml.S: Likewise. * sysdeps/i386/i686/fpu/s_fdim.S: Likewise. * sysdeps/i386/i686/fpu/s_fdimf.S: Likewise. * sysdeps/i386/i686/fpu/s_fdiml.S: Likewise. * sysdeps/powerpc/fpu/s_fdim.c: Likewise. * sysdeps/powerpc/fpu/s_fdimf.c: Likewise. * sysdeps/powerpc/powerpc32/fpu/s_fdim.c: Likewise. * sysdeps/powerpc/powerpc64/fpu/s_fdim.c: Likewise. * sysdeps/x86_64/fpu/s_fdiml.S: Likewise. * math/libm-test.inc (fdim_test_data): Expect errno setting on overflow. Add sNaN tests.
* Simplify generic fdim implementations.Joseph Myers2016-06-143-30/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The generic fdim implementations have unnecessarily complicated code, using fpclassify to determine whether the arguments are NaNs, subtracting NaNs if so and otherwise subtracting the non-NaN arguments if not (x <= y), then using fpclassify on the result to see if it is infinite. This patch simplifies the code. Instead of handling NaNs separately, it suffices to use an unordered comparison with islessequal (x, y) to determine whether to return zero, and otherwise NaNs can go through the same subtraction as non-NaN arguments; no explicit tests for NaN are needed at all. Then, isinf instead of fpclassify can be used to determine whether to set errno (in the normal non-overflow case, only one classification will need to occur, unlike the three in the previous code, of which two occurred even if returning zero, because the result will not be infinite in the normal case). The resulting logic is essentially the same as that in the powerpc version, except that the powerpc version is missing errno setting and uses <= not islessequal, so relying on <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58684>, the GCC bug that unordered comparison instructions are wrongly used on powerpc for ordered comparisons. The compiled code for fdim and fdimf on x86_64 is less than half the size of the previous code. Tested for x86_64. * math/s_fdim.c (__fdim): Use islessequal and isinf instead of fpclassify. * math/s_fdimf.c (__fdimf): Likewise. * math/s_fdiml.c (__fdiml): Likewise.
* Fix dbl-64 atan2 (sNaN, qNaN) (bug 20252).Joseph Myers2016-06-131-0/+62
| | | | | | | | | | | | | | | | | | The dbl-64 implementation of atan2, passed arguments (sNaN, qNaN), fails to raise the "invalid" exception. This patch fixes it to add both arguments, rather than just adding the second argument to itself, in the case where the second argument is a NaN (which is checked for before checking for the first argument being a NaN). sNaN tests for atan2 are added, along with some qNaN tests I noticed were missing but should have been there by analogy with other tests present. Tested for x86_64 and x86. [BZ #20252] * sysdeps/ieee754/dbl-64/e_atan2.c (__ieee754_atan2): Add both arguments when second argument is a NaN. * math/libm-test.inc (atan2_test_data): Add sNaN tests and more qNaN tests.
* Add more sNaN tests (cimag, conj, copysign, creal, fma, fmod).Joseph Myers2016-06-131-0/+95
| | | | | | | | | | | | | This patch adds tests of sNaN inputs to further libm functions. Tested for x86_64 and x86. * math/libm-test.inc (cimag_test_data): Add sNaN tests. (conj_test_data): Likewise. (copysign_test_data): Likewise. (creal_test_data): Likewise. (fma_test_data): Likewise. (fmod_test_data): Likewise.
* Fix frexp (NaN) (bug 20250).Joseph Myers2016-06-131-0/+2
| | | | | | | | | | | | | | | | | | | | | Various implementations of frexp functions return sNaN for sNaN input. This patch fixes them to add such arguments to themselves so that qNaN is returned. Tested for x86_64, x86, mips64 and powerpc. [BZ #20250] * sysdeps/i386/fpu/s_frexpl.S (__frexpl): Add non-finite input to itself. * sysdeps/ieee754/dbl-64/s_frexp.c (__frexp): Add non-finite or zero input to itself. * sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c (__frexp): Likewise. * sysdeps/ieee754/flt-32/s_frexpf.c (__frexpf): Likewise. * sysdeps/ieee754/ldbl-128/s_frexpl.c (__frexpl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_frexpl.c (__frexpl): Likewise. * sysdeps/ieee754/ldbl-96/s_frexpl.c (__frexpl): Likewise. * math/libm-test.inc (frexp_test_data): Add sNaN tests.
* Fix modf (sNaN) (bug 20240).Joseph Myers2016-06-102-0/+8
| | | | | | | | | | | | | | | | | | | | | Various modf implementations return sNaN (both outputs) for sNaN input. In fact they contain code to convert sNaN to qNaN for both outputs, but the way this is done is multiplying by 1.0 (for a wider range of inputs that includes NaNs as well as numbers with exponent large enough to ensure that they are integers), and that multiplication by 1.0 is optimized away by GCC in the absence of -fsignaling-nans, unlike other operations on NaNs used for this purpose that are not no-ops for non-sNaN input. This patch arranges for those files to be built with -fsignaling-nans so that this existing code is effective as intended. Tested for x86_64 and x86. [BZ #20240] * math/Makefile (CFLAGS-s_modf.c): New variable. (CFLAGS-s_modff.c): Likewise. (CFLAGS-s_modfl.c): Likewise. * math/libm-test.inc (modf_test_data): Add sNaN tests.
* Fix i386/x86_64 log2l (sNaN) (bug 20235).Joseph Myers2016-06-091-0/+2
| | | | | | | | | | | | | | The i386/x86_64 versions of log2l return sNaN for sNaN input. This patch fixes them to add NaN inputs to themselves so that qNaN is returned in this case. Tested for x86_64 and x86. [BZ #20235] * sysdeps/i386/fpu/e_log2l.S (__ieee754_log2l): Add NaN input to itself. * sysdeps/x86_64/fpu/e_log2l.S (__ieee754_log2l): Likewise. * math/libm-test.inc (log2_test_data): Add sNaN tests.
* Fix i386/x86_64 log1pl (sNaN) (bug 20229).Joseph Myers2016-06-081-0/+2
| | | | | | | | | | | | | The i386/x86_64 versions of log1pl return sNaN for sNaN input. This patch fixes them to add a NaN input to itself so that qNaN is returned in this case. Tested for x86_64 and x86. [BZ #20229] * sysdeps/i386/fpu/s_log1pl.S (__log1pl): Add NaN input to itself. * sysdeps/x86_64/fpu/s_log1pl.S (__log1pl): Likewise. * math/libm-test.inc (log1p_test_data): Add sNaN tests.
* Fix i386/x86_64 log10l (sNaN) (bug 20228).Joseph Myers2016-06-081-0/+2
| | | | | | | | | | | | | | The i386/x86_64 versions of log10l return sNaN for sNaN input. This patch fixes them to add a NaN input to itself so that qNaN is returned in this case. Tested for x86_64 and x86. [BZ #20228] * sysdeps/i386/fpu/e_log10l.S (__ieee754_log10l): Add NaN input to itself. * sysdeps/x86_64/fpu/e_log10l.S (__ieee754_log10l): Likewise. * math/libm-test.inc (log10_test_data): Add sNaN tests.
* Fix i386/x86_64 logl (sNaN) (bug 20227).Joseph Myers2016-06-081-0/+2
| | | | | | | | | | | | | | | | The i386/x86_64 versions of logl return sNaN for sNaN input. This patch fixes them to add a NaN input to itself so that qNaN is returned in this case. Tested for x86_64 and x86 (including a build for i586 to cover the non-i686 logl version). [BZ #20227] * sysdeps/i386/fpu/e_logl.S (__ieee754_logl): Add NaN input to itself. * sysdeps/i386/i686/fpu/e_logl.S (__ieee754_logl): Likewise. * sysdeps/x86_64/fpu/e_logl.S (__ieee754_logl): Likewise. * math/libm-test.inc (log_test_data): Add sNaN tests.
* Fix i386/x86_64 expl, exp10l, expm1l for sNaN input (bug 20226).Joseph Myers2016-06-081-0/+6
| | | | | | | | | | | | | | | | | The i386 and x86_64 implementations of expl, exp10l and expm1l (code shared between the functions) return sNaN for sNaN input. This patch fixes them to add NaN inputs to themselves so that qNaN is returned in this case. Tested for x86_64 and x86. [BZ #20226] * sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL): Add NaN argument to itself. * sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL): Likewise. * math/libm-test.inc (exp_test_data): Add sNaN tests. (exp10_test_data): Likewise. (expm1_test_data): Likewise.
* Fix ldexp, scalbn, scalbln for sNaN input (bug 20225).Joseph Myers2016-06-087-6/+10
| | | | | | | | | | | | | | | | | | | | The wrapper implementations of ldexp / scalbn / scalbln (architecture-independent), and their float / long double variants, return sNaN for sNaN input. This patch fixes them to add relevant arguments to themselves so that qNaN is returned in this case. Tested for x86_64 and x86. [BZ #20225] * math/s_ldexp.c (__ldexp): Add non-finite or zero argument to itself. * math/s_ldexpf.c (__ldexpf): Likewise. * math/s_ldexpl.c (__ldexpl): Likewise. * math/w_scalbln.c (__w_scalbln): Likewise. * math/w_scalblnf.c (__w_scalblnf): Likewise. * math/w_scalblnl.c (__w_scalblnl): Likewise. * math/libm-test.inc (scalbn_test_data): Add sNaN tests. (scalbln_test_data): Likewise.
* Fix i386 cbrtl (sNaN) (bug 20224).Joseph Myers2016-06-081-0/+2
| | | | | | | | | | | | | | | The i386 version of cbrtl returns sNaN (without raising any exceptions) for sNaN input. This patch fixes it to add non-finite arguments to themselves (the code path in question is also reached for zero arguments, for which adding them to themselves is also harmless), so that "invalid" is raised and qNaN returned. Tested for x86_64 and x86. [BZ #20224] * sysdeps/i386/fpu/s_cbrtl.S (__cbrtl): Add non-finite or zero argument to itself. * math/libm-test.inc (cbrt_test_data): Add sNaN tests.
* Generate new format names in auto-libm-test-outPaul E. Murphy2016-06-083-307667/+307655
| | | | | | | | This converts the inclusion macro for each test to use the format specific macro. In addition, the format specifier is removed as it is applied via the LIT() macro which is itself applied when converting the auto inputs and libm-test.inc into libm-test.c.
* Remove type specific information from auto-libm-test-inPaul E. Murphy2016-06-082-2864/+2865
| | | | | | | | | | | | | Apply the following sed regexes to auto-libm-test-in in order: s/flt-32/binary32/ s/dbl-64/binary64/ s/ldbl-96-intel/intel96/ s/ldbl-96-m68k/m68k96/ s/ldbl-128ibm/ibm128/ s/ldbl-128/binary128/ and fixup ldbl-96 comment manually.
* Remove CHOOSE() macro from libm-tests.incPaul E. Murphy2016-06-0820-39/+41
| | | | | | | | | | Use gen-libm-test.pl to generate a list of macros mapping to libm-test-ulps.h as this simplifies adding new types without having to modify a growing number of static headers each time a type is added. This also removes the final usage of the TEST_(DOUBLE|FLOAT|LDOUBLE) macros. Thus, they too are removed.
* Apply LIT(x) to floating point literals in libm-test.cPaul E. Murphy2016-06-082-95/+133
| | | | | | | | | | | | | | | | | | With the exception of the second argument of nexttoward, any suffixes should be stripped from the test input, and the macro LIT(x) should be applied to use the correct suffix for the type being tested. This adds a new argument type "j" to gen-test-libm.pl to signify an argument to a test input which does not require fixup. The test cases of nexttoward have been updated to use this new feature. This applies post-processing to all of the test inputs through gen-libm-test.pl to strip literal suffixes and apply the LIT(x) macro, with one exception stated above. This seems a bit cleaner than tossing the macro onto everything, albeit slightly more obfuscated.
* Fix i386 atanhl (sNaN) (bug 20219).Joseph Myers2016-06-071-0/+2
| | | | | | | | | | | | | The i386 version of atanhl returns sNaN for sNaN input. This patch fixes it to add NaN arguments to themselves so it returns qNaN in this case. Tested for x86_64 and x86. [BZ #20219] * sysdeps/i386/fpu/e_atanhl.S (__ieee754_atanhl): Add NaN argument to itself. * math/libm-test.inc (atanh_test_data): Add sNaN tests.
* Fix i386 asinhl (sNaN) (bug 20218).Joseph Myers2016-06-071-0/+2
| | | | | | | | | | | | | | The i386 version of asinhl returns sNaN (without raising any exceptions) for sNaN input. This patch fixes it to add non-finite arguments to themselves, so that "invalid" is raised and qNaN returned. Tested for x86_64 and x86. [BZ #20218] * sysdeps/i386/fpu/s_asinhl.S (__asinhl): Add non-finite argument to itself. * math/libm-test.inc (asinh_test_data): Add sNaN tests.
* Fix dbl-64 asin (sNaN) (bug 20213).Joseph Myers2016-06-061-0/+2
| | | | | | | | | | | | | The dbl-64 version of asin returns sNaN for sNaN arguments. This patch fixes it to add NaN arguments to themselves so that qNaN is returned in this case. Tested for x86_64 and x86. [BZ #20213] * sysdeps/ieee754/dbl-64/e_asin.c (__ieee754_asin): Add NaN argument to itself. * math/libm-test.inc (asin_test_data): Add sNaN tests.
* Fix dbl-64 acos (sNaN) (bug 20212).Joseph Myers2016-06-061-0/+2
| | | | | | | | | | | | | The dbl-64 version of acos returns sNaN for sNaN arguments. This patch fixes it to add NaN arguments to themselves so that qNaN is returned in this case. Tested for x86_64 and x86. [BZ #20212] * sysdeps/ieee754/dbl-64/e_asin.c (__ieee754_acos): Add NaN argument to itself. * math/libm-test.inc (acos_test_data): Add sNaN tests.
* Fix x86/x86_64 nextafterl incrementing negative subnormals (bug 20205).Joseph Myers2016-06-031-0/+4
| | | | | | | | | | | | | | | | | The x86 / x86_64 implementation of nextafterl (also used for nexttowardl) produces incorrect results (NaNs) when negative subnormals, the low 32 bits of whose mantissa are zero, are incremented towards zero. This patch fixes this by disabling the logic to decrement the exponent in that case. Tested for x86_64 and x86. [BZ #20205] * sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Do not adjust exponent when incrementing negative subnormal with low mantissa word zero. * math/libm-test.inc (nextafter_test_data) [TEST_COND_intel96]: Add another test.
* Replace M_El with lit_e in libm-test.incPaul E. Murphy2016-05-271-3/+8
| | | | | This is useful in situations where the long double type is less precise than the type under test.
* Replace M_PI_4l with lit_pi_4_d in libm-test.incPaul E. Murphy2016-05-271-26/+28
| | | | | This is useful in situations where the long double type is less precise than the type under test.
* Replace M_PIl with lit_pi in libm-test.incPaul E. Murphy2016-05-271-38/+40
| | | | | This is useful in situations where the long double type is less precise than the type under test.
* Replace M_PI2l with lit_pi_2_d in libm-test.incPaul E. Murphy2016-05-274-157/+163
| | | | | | | This is useful in situations where the long double type is less precise than the type under test. This adds a new wrapper macro LITM(x) to each type to append the proper suffix onto macro constants found in math.h.
* Refactor M_ macros defined in libm-test.incPaul E. Murphy2016-05-271-33/+41
| | | | | | | | | These are local to the test suite. Rename them as a macro starting with lit_pi and a series of postfix operations to give us a constant starting with lit_pi. The lit prefix is intended to enable easy substitutions via gen-test-libm.pl if needed.
* Remove unused macros from libm-test.inc.Joseph Myers2016-05-271-25/+0
| | | | | | | | | | | | | | | | | | This patch removes various no-longer-used macros from libm-test.inc. NO_TEST_INLINE_FLOAT, NO_TEST_INLINE_DOUBLE and M_PI_6l would have been used before relevant tests were moved to auto-libm-test-in. TEST_COND_x86_64 and TEST_COND_x86 were for tests in auto-libm-test-in XFAILed for x86, and are no longer relevant now the bugs in question have been fixed and the XFAILing removed (if future x86-specific XFAILs become needed, they can always be added back). Tested for x86_64 and x86. * math/libm-test.inc (NO_TEST_INLINE_FLOAT): Remove macro. (NO_TEST_INLINE_DOUBLE): Likewise. (TEST_COND_x86_64): Likewise. (TEST_COND_x86): Likewise. (M_PI_6l): Likewise.
* Refactor type specific macros using regexesPaul E. Murphy2016-05-271-343/+331
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace most of the type specific macros with the equivalent type-generic macro using the following sed replacement command below: sed -ri -e 's/defined TEST_FLOAT/TEST_COND_binary32/' \ -e 's/ndef TEST_FLOAT/ !TEST_COND_binary32/' \ -e 's/def TEST_FLOAT/ TEST_COND_binary32/' \ -e 's/defined TEST_DOUBLE/TEST_COND_binary64/'\ -e 's/ndef TEST_DOUBLE/ !TEST_COND_binary64/' \ -e 's/def TEST_DOUBLE/ TEST_COND_binary64/' \ -e 's/defined TEST_LDOUBLE && //' \ -e 's/ifdef TEST_LDOUBLE/if MANT_DIG >= 64/' \ -e 's/defined TEST_LDOUBLE/MANT_DIG >= 64/' \ -e '/nexttoward_test_data\[\]/,/ };/!s/LDBL_(MIN_EXP|MAX_EXP|MANT_DIG)/\1/g' \ libm-test.inc With a little extra manual cleanup to simplify the following case: #if MANT_DIG >= 64 # if MANT_DIG >= 64 ... # endif ... Note, TEST_LDOUBLE checks are replaced by MANT_DIG >= 64 excepting where another property of the type is being tested. And, the final regex is intended to avoid replacing LDBL_ macro usage within the nexttoward tests which explicitly take argument 2 as long double.
* Begin refactor of libm-test.incPaul E. Murphy2016-05-274-94/+127
| | | | | | | | | | | Attempt to creatively redefine the macros to choose tests based on the format being tested, not the type. Note, TS 18661 does not define any printf modifiers, so we need to be a little more verbose about constructing strings to output.
* Add more sNaN tests to libm-test.inc.Joseph Myers2016-05-261-0/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds more tests of signaling NaN inputs to libm-test.inc. These tests are for a subset of functions with a single floating-point input where no failures appeared in x86_64 or x86 testing. I intend to investigate any failures of these new tests on some other architectures before dealing with other functions. Tested for x86_64 and x86. * math/libm-test.inc (acosh_test_data): Add sNaN tests. (atan_test_data): Likewise. (ceil_test_data): Likewise. (cos_test_data): Likewise. (cosh_test_data): Likewise. (erf_test_data): Likewise. (exp2_test_data): Likewise. (fabs_test_data): Likewise. (floor_test_data): Likewise. (ilogb_test_data): Likewise. (j0_test_data): Likewise. (j1_test_data): Likewise. (jn_test_data): Likewise. (lgamma_test_data): Likewise. (lrint_test_data): Likewise. (llrint_test_data): Likewise. (logb_test_data): Likewise. (lround_test_data): Likewise. (llround_test_data): Likewise. (nearbyint_test_data): Likewise. (rint_test_data): Likewise. (round_test_data): Likewise. (sin_test_data): Likewise. (sincos_test_data): Likewise. (sinh_test_data): Likewise. (sqrt_test_data): Likewise. (tan_test_data): Likewise. (tanh_test_data): Likewise. (tgamma_test_data): Likewise. (trunc_test_data): Likewise. (y0_test_data): Likewise. (y1_test_data): Likewise. (yn_test_data): Likewise.
* Support sNaN testing in libm-test.inc.Joseph Myers2016-05-263-8/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support in libm-test.inc for tests with signaling NaN arguments. gen-libm-test.pl is made to set a flag TEST_SNAN for such tests, so that they can be disabled automatically when sNaN testing isn't supported for a given type (at present, for float and double on 32-bit x86 because it's unpredictable when a value might be loaded into a floating-point register and so automatically converted to long double with sNaNs converted to quiet NaNs). -fsignaling-nans is used where needed. Tests are added for classification macros, as a starting point; this is deliberately more conservative than Thomas's patch <https://sourceware.org/ml/libc-ports/2013-04/msg00008.html>, to allow more tests to be added, and issues exposed fixed, bit by bit. Tested for x86_64 and x86. * math/libm-test.inc: Update comment about NaN testing. (TEST_SNAN): New macro. (snan_value): Likewise. (enable_test): Disable tests of sNaNs when SNAN_TESTS fails. (fpclassify_test_data): Add sNaN tests. (isfinite_test_data): Likewise. (isinf_test_data): Likewise. (isnan_test_data): Likewise. (isnormal_test_data): Likewise. (issignaling_test_data): Likewise. (signbit_test_data): Likewise. * math/gen-libm-test.pl (%beautify): Add snan_value. (show_exceptions): Add argument $test_snan. (parse_args): Handle snan_value as non-finite. Update call to show_exceptions. * math/Makefile (libm-test-no-inline-cflags): Add -fsignaling-nans.
* Fixup usage of MIN_EXP in libm-test.incPaul E. Murphy2016-05-241-11/+11
| | | | | Make MANT_DIG shadow the types *_MIN_EXP macro. Replace calls sites with (MIN_EXP - 1), and simplify.
* Fixup usage of MANT_DIG in libm-test.incPaul E. Murphy2016-05-241-46/+46
| | | | | Make MANT_DIG shadow the types *_MANT_DIG macro. Replace calls sites with (MANT_DIG - 1), and simplify.
* Do not raise "inexact" from generic round (bug 15479).Joseph Myers2016-05-241-85/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C99 and C11 allow but do not require ceil, floor, round and trunc to raise the "inexact" exception for noninteger arguments. TS 18661-1 requires that this exception not be raised by these functions. This aligns them with general IEEE semantics, where "inexact" is only raised if the final step of rounding the infinite-precision result to the result type is inexact; for these functions, the infinite-precision integer result is always representable in the result type, so "inexact" should never be raised. The generic implementations of ceil, floor and round functions contain code to force "inexact" to be raised. This patch removes it for round functions to align them with TS 18661-1 in this regard. The tests *are* updated by this patch; there are fewer architecture-specific versions than for ceil and floor, and I fixed the powerpc ones some time ago. If any others still have the issue, as shown by tests for round failing with spurious exceptions, they can be fixed separately by architecture maintainers or others. Tested for x86_64, x86 and mips64. [BZ #15479] * sysdeps/ieee754/dbl-64/s_round.c (huge): Remove variable. (__round): Do not force "inexact" exception. * sysdeps/ieee754/dbl-64/wordsize-64/s_round.c (huge): Remove variable. (__round): Do not force "inexact" exception. * sysdeps/ieee754/flt-32/s_roundf.c (huge): Remove variable. (__roundf): Do not force "inexact" exception. * sysdeps/ieee754/ldbl-128/s_roundl.c (huge): Remove variable. (__roundl): Do not force "inexact" exception. * sysdeps/ieee754/ldbl-96/s_roundl.c (huge): Remove variable. (__roundl): Do not force "inexact" exception. * math/libm-test.inc (round_test_data): Do not allow spurious "inexact" exceptions.
* Implement proper fmal for ldbl-128ibm (bug 13304).Joseph Myers2016-05-192-6137/+6136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ldbl-128ibm had an implementation of fmal that just did (x * y) + z in most cases, with no attempt at actually being a fused operation. This patch replaces it with a genuine fused operation. It is not necessarily correctly rounding, but should produce a result at least as accurate as the long double arithmetic operations in libgcc, which I think is all that can reasonably be expected for such a non-IEEE format where arithmetic is approximate rather than rounded according to any particular rule for determining the exact result. Like the libgcc arithmetic, it may produce spurious overflow and underflow results, and it falls back to the libgcc multiplication in the case of (finite, finite, zero). This concludes the fixes for bug 13304; any subsequently found fma issues should go in separate Bugzilla bugs. Various other pieces of bug 13304 were fixed in past releases over the past several years. Tested for powerpc. [BZ #13304] * sysdeps/ieee754/ldbl-128ibm/s_fmal.c: Include <fenv.h>, <float.h>, <math_private.h> and <stdlib.h>. (add_split): New function. (mul_split): Likewise. (ext_val): New typedef. (store_ext_val): New function. (mul_ext_val): New function. (compare): New function. (add_split_ext): New function. (__fmal): After checking for Inf, NaN and zero, compute result as an exact sum of scaled double values in round-to-nearest before adding those up and adjusting for other rounding modes. * math/auto-libm-test-in: Remove xfail-rounding:ldbl-128ibm from tests of fma. * math/auto-libm-test-out: Regenerated.
* Update libm-test.inc comment about NaN signs.Joseph Myers2016-05-181-2/+1
| | | | | | | | | | | | | | | | libm-test.inc has a comment about signs of NaNs not being tested. This is out of date since: commit ce66581742e7ae1d6ce59e5d2d4859b2ae41218c Author: Joseph Myers <joseph@codesourcery.com> Date: Sat Nov 16 12:48:35 2013 +0000 Test signs of NaNs in libm-test.inc where appropriate. This patch removes the inaccurate statement. * math/libm-test.inc: Update comment not to refer to signs of NaNs not being tested.
* Register extra test objectsAndreas Schwab2016-04-131-3/+7
| | | | | This makes sure that the extra test objects are compiled with the correct MODULE_NAME and dependencies are tracked.
* Fix x86_64 / x86 powl inaccuracy for integer exponents (bug 19848).Joseph Myers2016-03-242-0/+2593
| | | | | | | | | | | | | | | | | | | | | | | Bug 19848 reports cases where powl on x86 / x86_64 has error accumulation, for small integer exponents, larger than permitted by glibc's accuracy goals, at least in some rounding modes. This patch further restricts the exponent range for which the small-integer-exponent logic is used to limit the possible error accumulation. Tested for x86_64 and x86 and ulps updated accordingly. [BZ #19848] * sysdeps/i386/fpu/e_powl.S (p3): Rename to p2 and change value from 8 to 4. (__ieee754_powl): Compare integer exponent against 4 not 8. * sysdeps/x86_64/fpu/e_powl.S (p3): Rename to p2 and change value from 8 to 4. (__ieee754_powl): Compare integer exponent against 4 not 8. * math/auto-libm-test-in: Add more tests of pow. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
* math: don't clobber old libm.so on install [BZ #19822]Dylan Alex Simon2016-03-211-1/+2
| | | | | | | | | | | | When installing glibc (w/mathvec enabled) in-place on a system with a glibc w/out mathvec enabled, the install will clobber the existing libm.so (e.g., /lib64/libm-2.21.so) with a linker script. This is because libm.so is a symlink to libm.so.6 which is a symlink to the final libm-2.21.so file. When the makefile writes the linker script directly to libm.so, it gets clobbered. The simple patch below to math/Makefile fixes this. It is based on the nptl Makefile, which does exactly the same thing in a safer way.
* Fix building glibc master with NDEBUG and --with-cpu.Carlos O'Donell2016-03-152-2/+2
| | | | | | | | | | When building on i686, x86_64, and arm, and with NDEBUG, or --with-cpu there are various variables and functions which are unused based on these settings. This patch marks all such variables with __attribute__((unused)) to avoid the compiler warnings when building with the aformentioned options.
* Fix compilation of test-signgam-* testsAndreas Schwab2016-03-152-0/+2
|
* Allow spurious underflow / inexact for ldbl-128ibm.Joseph Myers2016-03-101-2/+9
| | | | | | | | | | | | | | | | | | | | | | A large number of the test-ldouble failures seen for ldbl-128ibm are spurious "underflow" and "inexact" exceptions. These arise from such exceptions in the underlying arithmetic; unlike other spurious exceptions from that arithmetic, they do not in general relate to cases where the returned result is also substantially inaccurate, are not so readily avoidable by appropriately conditional libgcc patches, and are widespread enough to be hard to handle through individual XFAILing of the affected tests. Thus, this patch documents relaxed accuracy goals for libm functions for IBM long double and makes libm-test.inc reflect these spurious exceptions in ldbl-128ibm arithmetic and always allow them in ldbl-128ibm testing (while still not allowing these exceptions to be missing where required to be present). Tested for powerpc. * manual/math.texi (Errors in Math Functions): Document relaxed accuracy goals for IBM long double. * math/libm-test.inc (test_exceptions): Always allow spurious "underflow" and "inexact" exceptions for IBM long double.
* Omit test-math-isinff when no C++ compiler.Roland McGrath2016-03-041-1/+4
|
* Don't use long double math functions if NO_LONG_DOUBLEAndreas Schwab2016-02-241-1/+6
|
* Fix ldbl-128ibm remainderl, remquol equality tests (bug 19603).Joseph Myers2016-02-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | The ldbl-128ibm implementations of remainderl and remquol have logic resulting in incorrect tests for equality of the absolute values of the arguments. Equality is tested based on the integer representations of the high and low parts, with the sign bit masked off the high part - but when this changes the sign of the high part, the sign of the low part needs to be changed as well, and failure to do this means arguments are wrongly treated as equal when they are not. This patch fixes the logic to adjust signs of low parts as needed. Tested for powerpc. [BZ #19603] * sysdeps/ieee754/ldbl-128ibm/e_remainderl.c (__ieee754_remainderl): Adjust sign of integer version of low part when taking absolute value of high part. * sysdeps/ieee754/ldbl-128ibm/s_remquol.c (__remquol): Likewise. * math/libm-test.inc (remainder_test_data): Add another test. (remquo_test_data): Likewise.
* Ensure isinff, isinfl, isnanf, and isnanl are defined (Bug 19439)Carlos O'Donell2016-02-143-2/+57
| | | | | | | In ICO C++11 mode ensure that isinff, isinfl, isnanf, and isnanl are defined. These functions were accidentally removed from the header as part of commit d9b965fa56350d6eea9f7f438a0714c7ffbb183f, but being GNU extensions, they should have been left in place.
* Fix ulps regeneration for *-finite tests.Joseph Myers2016-01-191-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On running tests after from-scratch ulps regeneration, I found that some libm tests failed with ulps in excess of those recorded in the from-scratch regeneration, which should never happen unless those ulps exceed the limit on ulps that can go in libm-test-ulps files. Failure: Test: atan2_upward (inf, -inf) Result: is: 2.35619498e+00 0x1.2d97ccp+1 should be: 2.35619450e+00 0x1.2d97c8p+1 difference: 4.76837159e-07 0x1.000000p-21 ulp : 2.0000 max.ulp : 1.0000 Maximal error of `atan2_upward' is : 2 ulp accepted: 1 ulp Failure: Test: carg_upward (-inf + inf i) Result: is: 2.35619498e+00 0x1.2d97ccp+1 should be: 2.35619450e+00 0x1.2d97c8p+1 difference: 4.76837159e-07 0x1.000000p-21 ulp : 2.0000 max.ulp : 1.0000 Maximal error of `carg_upward' is : 2 ulp accepted: 1 ulp The problem comes from the addition of tests for the finite-math-only versions of libm functions. Those tests share ulps with the default function variants. make regen-ulps runs the default tests before the finite-math-only tests, concatenating the resulting ulps before feeding them to gen-libm-test.pl to generate a new libm-test-ulps file. But gen-libm-test.pl always takes the last ulps value given for any (function, type) pair. So, if the largest ulps for a function come from non-finite inputs, a from-scratch regeneration loses those ulps. This patch fixes gen-libm-test.pl, in the case where there are multiple ulps values for a (function, type) pair - which can only happen as part of a regeneration - to take the largest ulps value rather than the last one. Tested for ARM / MIPS / powerpc-nofpu. * math/gen-libm-test.pl (parse_ulps): Do not reduce already-recorded ulps. * sysdeps/arm/libm-test-ulps: Regenerated. * sysdeps/mips/mips32/libm-test-ulps: Likewise. * sysdeps/mips/mips64/libm-test-ulps: Likewise. * sysdeps/powerpc/nofpu/libm-test-ulps: Likewise.