about summary refs log tree commit diff
path: root/sysdeps/ieee754
Commit message (Collapse)AuthorAgeFilesLines
* Update comments for some functions in s_sin.cSiddhesh Poyarekar2016-10-061-22/+17
| | | | | Update comments for some functions to bring them in sync with what the functions are actually doing.
* Adjust calls to do_sincos_1 and do_sincos_2 in s_sincos.cSiddhesh Poyarekar2016-10-061-4/+4
| | | | | | | Adjust calls to do_sincos_1 and do_sincos_2 to pass a boolean shift_quadrant instead of the numeric 0 and 1. This does not affect codegen.
* Make quadrant shift a boolean in reduce_and_compute in s_sin.cSiddhesh Poyarekar2016-10-061-4/+4
| | | | | | | | Like the previous change, make the quadrant shift a boolean to make it clearer that we will do at most a single rotation of the quadrants to compute the cosine from the sine function. This does not affect codegen.
* Check n instead of k1 to decide on sign of sin/cos resultSiddhesh Poyarekar2016-10-061-1/+1
| | | | | | | | | | | | | | | | | | | | | For k1 in 1 and 3, n can only have values of 0 and 2, so checking k1 & 2 is equivalent to checking n & 2. We prefer the latter so that we don't use k1 for anything other than selecting the quadrant in do_sincos_1, thus dropping it completely. The previous logic was: "Compute sine for the value and based on the new rotated quadrant (k1) negate the value if we're in the fourth quadrant." With this change, the logic now is: "Compute sine for the value and negate it if we were either (1) in the fourth quadrant or (2) we actually wanted the cosine and were in the third quadrant." * sysdeps/ieee754/dbl-64/s_sin.c (do_sincos_1): Check N instead of K1.
* Make the quadrant shift K a bool in do_sincos_* functionsSiddhesh Poyarekar2016-10-061-19/+19
| | | | | | | | | | | | | | | | The do_sincos_* functions are helpers to compute sin/cos, where they get cosine by computing sine for the next quadrant. This is decided with the value of K passed to it, which is the amount by which to shift the quadrant. Since we will only need the shift to be 0 or 1, we make K a bool to make that explicit. * sysdeps/ieee754/dbl-64/s_sin.c (do_sincos_1): Rename K to SHIFT_QUADRANT and make it bool. (do_sincos_2): Likewise. (sloww): Likewise. (sloww1): Likewise. (__sin): Adjust calls to do_sincos_1 and do_sincos_2. (__cos): Likewise.
* Use __builtin_fma more in dbl-64 code.Joseph Myers2016-09-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sysdeps/ieee754/dbl-64/dla.h can use a macro DLA_FMS for more efficient double-width operations when fused multiply-subtract is supported. However, this macro is only defined for x86_64, conditional on architecture-specific __FMA4__. This patch makes the code use __builtin_fma conditional on __FP_FAST_FMA, as used elsewhere in glibc. Tested for x86_64, x86 and powerpc. On powerpc (where this is causing fused operations to be used where they weren't previously) I see an increase from 1ulp to 2ulp in the imaginary part of clog10: testing double (without inline functions) Failure: Test: Imaginary part of: clog10 (0x1.7a858p+0 - 0x6.d940dp-4 i) Result: is: -1.2237865208199886e-01 -0x1.f5435146bb61ap-4 should be: -1.2237865208199888e-01 -0x1.f5435146bb61cp-4 difference: 2.7755575615628914e-17 0x1.0000000000000p-55 ulp : 2.0000 max.ulp : 1.0000 Maximal error of real part of: clog10 is : 3 ulp accepted: 3 ulp Maximal error of imaginary part of: clog10 is : 2 ulp accepted: 1 ulp This is actually resulting from atan2 becoming *more* accurate (atan2 (-0x6.d940dp-4, 0x1.7a858p+0) should ideally be -0x1.208cd6e841554p-2 but was -0x1.208cd6e841555p-2 from a powerpc libm built before this change, and is -0x1.208cd6e841554p-2 from a powerpc libm built after this change). Since these functions are not expected to be correctly rounding by glibc's accuracy goals, neither result is a problem, but this does imply that some of this code, although designed to be correctly rounding, is not in fact correctly rounding (possibly because of GCC creating fused operations where the code does not expect it, something we've only disabled for specific functions where it was found to cause large errors). (Of course as previously discussed I think we should remove the slow cases where an error analysis shows this wouldn't increase the errors much above 0.5ulp; it's only functions such as cratan2 that are expected to be correctly rounding, not atan2.) * sysdeps/ieee754/dbl-64/dla.h [__FP_FAST_FMA] (DLA_FMS): Define macro to use __builtin_fma. * sysdeps/x86_64/fpu/dla.h: Remove file.
* Fix ldbl-128ibm iscanonical for -mlong-double-64.Joseph Myers2016-09-301-1/+5
| | | | | | | | | | | This patch fixes the ldbl-128ibm version of the iscanonical macro not to use __iscanonicall when long double = double (-mlong-double-64). Tested for powerpc. * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h [__NO_LONG_DOUBLE_MATH] (__iscanonicall): Do not declare. [__NO_LONG_DOUBLE_MATH] (iscanonical): Define to evaluate to 1.
* Add iscanonical.Joseph Myers2016-09-308-1/+511
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TS 18661-1 adds an iscanonical classification macro to <math.h>. The motivation for this is decimal floating-point, where some values have both canonical and noncanonical encodings. For IEEE binary interchange formats, all encodings are canonical. For x86/m68k ldbl-96, and for ldbl-128ibm, there are encodings that do not represent any valid value of the type; although formally iscanonical does not need to handle trap representations (and so could just always return 1), it seems useful, and in line with the description in the TS of "representations that are extraneous to the floating-point model" as being non-canonical (as well as "redundant representations of some or all of its values"), for it to detect those representations and return 0 for them. This patch adds iscanonical to glibc. It goes in a header <bits/iscanonical.h>, included under appropriate conditions in <math.h>. The default header version just evaluates the argument (converted to its semantic type, though current GCC will probably discard that conversion and any exceptions resulting from it) and returns 1. ldbl-96 and ldbl-128ibm then have versions of the header that call a function __iscanonicall for long double (the sizeof-based tests will of course need updating for float128 support, like other such type-generic macro implementations). The ldbl-96 version of __iscanonicall has appropriate conditionals to reflect the differences in the m68k version of that format (where the high mantissa bit may be either 0 or 1 when the exponent is 0 or 0x7fff). Corresponding tests for those formats are added as well. Other architectures do not have any new functions added because just returning 1 is correct for all their floating-point formats. Tested for x86_64, x86, mips64 (to test the default macro version) and powerpc. * math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT)]: Include <bits/iscanonical.h>. * bits/iscanonical.h: New file. * math/s_iscanonicall.c: Likewise. * math/Versions (__iscanonicall): New libm symbol at version GLIBC_2.25. * math/libm-test.inc (iscanonical_test_data): New array. (iscanonical_test): New function. (main): Call iscanonical_test. * math/Makefile (headers): Add bits/iscanonical.h. (type-ldouble-routines): Add s_iscanonicall. * manual/arith.texi (Floating Point Classes): Document iscanonical. * manual/libm-err-tab.pl: Update comment on interfaces without ulps tabulated. * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h: New file. * sysdeps/ieee754/ldbl-128ibm/s_iscanonicall.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/test-iscanonical-ldbl-128ibm.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/Makefile (tests): Add test-iscanonical-ldbl-128ibm. * sysdeps/ieee754/ldbl-96/bits/iscanonical.h: New file. * sysdeps/ieee754/ldbl-96/s_iscanonicall.c: Likewise. * sysdeps/ieee754/ldbl-96/test-iscanonical-ldbl-96.c: Likewise. * sysdeps/ieee754/ldbl-96/Makefile: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Update. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
* Use copysign instead of ternary for some sin/cos input rangesSiddhesh Poyarekar2016-09-301-13/+13
| | | | | | | | | | | | | | | | | | | These are remaining cases where we can deduce and conclude that the sign of the result should be the same as the sign of the input being checked. For example, for sin(x), the sign of the result is the same as the result itself for x < pi. Likewise, for sine values where x after range reduction falls into this range and its sign is preserved. * sysdeps/ieee754/dbl-64/s_sin.c (do_sincos_1): Use copysign instead of ternary condition. (do_sincos_2): Likewise. (__sin): Likewise. (__cos): Likewise. (slow): Likewise. (sloww): Likewise. (sloww1): Likewise. (bsloww): Likewise. (bsloww1): Likewise.
* Use copysign instead of ternary conditions for positive constantsSiddhesh Poyarekar2016-09-301-19/+19
| | | | | | | | | | | | | | | | | | This is the first very simple substitution of ternary conditions for correction adjustments with __copysign for positive constants. * sysdeps/ieee754/dbl-64/s_sin.c (do_cos_slow): use copysign instead of ternary condition. (do_sin_slow): Likewise. (do_sincos_1): Likewise. (do_sincos_2): Likewise. (__cos): Likewise. (sloww): Likewise. (sloww1): Likewise. (sloww2): Likewise. (bsloww): Likewise. (bsloww1): Likewise. (bsloww2): Likewise.
* consolidate sign checks for slow2Siddhesh Poyarekar2016-09-301-8/+10
| | | | | | | | | | Simplify the code a bit by consolidating sign checks in slow1 and slow2 into __sin at the higher level. * sysdeps/ieee754/dbl-64/s_sin.c (slow1): Consolidate sign check from here... (slow2): ... and here... (__sin): ... to here.
* Build s_nan* objects from a generic templatePaul E. Murphy2016-09-203-10/+1
| | | | | | | This requires adding a macro to synthesize the call to __strto*_nan. Since this is likely to be the only usage ever for strto* functions in generated libm calls, a dedicated macro is defined for it.
* Make ldexpF generic.Paul E. Murphy2016-09-202-6/+46
| | | | | | | | | | | | | | | | | This one is a little more tricky since it is built both for libm and libc, and exports multiple aliases. To simplify aliasing, a new macro is introduced which handles aliasing to two symbols. By default, it just applies declare_mgen_alias to both target symbols. Likewise, the makefile is tweaked a little to generate templates for shared files too, and a new rule is added to build m_*.c objects from the objpfx directory. Verified there are no symbol or code changes using a script to diff the *_ldexp* object files on s390x, aarch64, arm, x86_64, and ppc64.
* ldbl-128: Use L(x) macro for long double constantsPaul E. Murphy2016-09-1350-3925/+3925
| | | | | | | | | | | | | | | | | | | | This runs the attached sed script against these files using a regex which aggressively matches long double literals when not obviously part of a comment. Likewise, 5 digit or less integral constants are replaced with integer constants, excepting the two cases of 0 used in large tables, which are also the only integral values of the form x.0*E0L encountered within these converted files. Likewise, -L(x) is transformed into L(-x). Naturally, the script has a few minor hiccups which are more clearly remedied via the attached fixup patch. Such hiccups include, context-sensitive promotion to a real type, and munging constants inside harder to detect comment blocks.
* Inline all support functions for sin and cosSiddhesh Poyarekar2016-09-021-24/+28
| | | | | | | | | | | | | | | | | | | | | | The support functions for sin and cos have a lot of identical functionality, so inlining them gives a pretty decent jump in functionality: ~19% in the sincos function. On SPEC2006 this translates to about 2.1% in the tonto test. * sysdeps/ieee754/dbl-64/s_sin.c (do_cos): Mark as inline. (do_cos_slow): Likewise. (do_sin): Likewise. (do_sin_slow): Likewise. (slow): Likewise. (slow1): Likewise. (slow2): Likewise. (sloww): Likewise. (sloww1): Likewise. (sloww2): Likewise. (bsloww): Likewise. (bsloww1): Likewise. (bsloww2): Likewise. (cslow2): Likewise.
* Use do_sin for sin(x) where 0.25 < |x| < 0.855469Siddhesh Poyarekar2016-09-021-18/+3
| | | | | | | | The only code looks slightly different from do_sin but on closer examination, should give exactly the same result. Drop it in favour of the do_sin function call. * sysdeps/ieee754/dbl-64/s_sin.c (__sin): Use do_sin.
* Consolidate input partitioning into do_cos and do_sinSiddhesh Poyarekar2016-09-021-109/+82
| | | | | | | | | | | | | | | | | | | | | | | | All calls to do_cos are preceded by code that partitions x into a larger double that gives an offset into the sincos table and a smaller double that is used in a polynomial computation. Consolidate all of them into do_cos and do_sin to reduce code duplication. * sysdeps/ieee754/dbl-64/s_sin.c (do_cos): Accept X and DX as input arguments. Consolidate input partitioning from callers here. (do_cos_slow): Likewise. (do_sin): Likewise. (do_sin_slow): Likewise. (do_sincos_1): Remove the no longer necessary input partitioning. (do_sincos_2): Likewise. (__sin): Likewise. (__cos): Likewise. (slow1): Likewise. (slow2): Likewise. (sloww1): Likewise. (sloww2): Likewise. (bsloww1): Likewise. (bsloww2): Likewise. (cslow2): Likewise.
* Make common fmin implementation generic.Paul E. Murphy2016-09-013-10/+1
|
* Make common fmax implementation generic.Paul E. Murphy2016-09-013-10/+1
| | | | | Also update aarch64 to ensure the correct s_fmin.c is included. The include order favors including the generated copy.
* Make common nextdown implementation generic.Paul E. Murphy2016-09-011-0/+5
| | | | | | | | | | With the exception of those machines using the ldbl-opt in an Implies file, this is a trivial transformation. nextdownl is not subject to the non-trivial versioning rules of the other generated functions, so to keep things simple, it is handled as a one-off case in ldbl-opt to preserve the existing behavior.
* Make common fdim implementation generic.Paul E. Murphy2016-09-014-13/+10
| | | | | | | | | | | | | | The only difference is the usage of math_narrow_eval when building s_fdiml.c. This should be harmless for long double, but I did observe some code generation changes on m68k, but lack the resources to test it. Likewise, to more easily support overriding symbol generation, the aliasing macros are always conditionally defined on their absence to reduce boilerplate. I also ran builds for i486, ppc64, sparcv9, aarch64, s390x and observed no changes to s_fdim* objects.
* ldbl-128: Cleanup e_gammal_r.c after _Float128 renamePaul E. Murphy2016-08-311-6/+6
|
* ldbl-128: Rename 'long double' to '_Float128'Paul E. Murphy2016-08-3177-620/+646
| | | | | | | | | | | | | | | | | | Add a layer of macro indirection for long double files which need to be built using another typename. Likewise, add the L(num) macro used in a later patch to override real constants. These macros are only defined through the ldbl-128 math_ldbl.h header, thereby implicitly restricting these macros to machines which back long double with an IEEE binary128 format. Likewise, appropriate changes are made for the few files which indirectly include such ldbl-128 files. These changes produce identical binaries for s390x, aarch64, and ppc64.
* Use fabs(x) instead of branching on signedness of input to sin and cosSiddhesh Poyarekar2016-08-301-148/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The sin and cos code is inconsistent about its use of fabs to get the absolute value of X where in some places it conditionalizes the code while in others it uses fabs. fabs seems to be a better candidate in most cases because it avoids a branch. Similarly there is an attempt to make it easier for the compiler to emit conditional assignment instructions (like fcsel on aarch64) where it can, by isolating conditional assignment constructs from the rest of the expression. A further benefit of this change is to identify common constructs across functions and consolidate them in future patches. * sysdeps/ieee754/dbl-64/s_sin.c (do_cos_slow): Use ternary instead of if/else. (do_sin_slow): Likewise. (do_sincos_1): Use fabs instead of if/else. (do_sincos_2): Likewise. (__sin): Likewise. (__cos): Likewise. (slow2): Likewise. (sloww): Likewise. (sloww1): Likewise. Drop argument M. (sloww2): Use fabs instead of if/else. (bsloww): Likewise. (bsloww1): Likewise. (bsloww2): Likewise.
* Add fall through commentsSiddhesh Poyarekar2016-08-301-0/+2
| | | | Add fall through comments I had missed writing in previously.
* Consolidate reduce_and_compute codeSiddhesh Poyarekar2016-08-301-17/+14
| | | | | | | | | | | | This patch reshuffles the reduce_and_compute code so that the structure matches other code structures of the same type elsewhere in s_sin.c and s_sincos.c. This is the beginning of an attempt to consolidate and reduce code duplication in functions in s_sin.c to make it easier to read and possibly also easier for the compiler to optimize. * sysdeps/ieee754/dbl-64/s_sin.c (reduce_and_compute): Consolidate switch cases 0 and 2.
* Convert remaining complex function to generated filesPaul E. Murphy2016-08-2912-74/+28
| | | | | | Convert cpow, clog, clog10, cexp, csqrt, and cproj functions into generated templates. Note, ldbl-opt still retains s_clog10l.c as the aliasing rules are non-trivial.
* Convert _Complex tangent functions to generated codePaul E. Murphy2016-08-198-48/+0
| | | | | | This converts s_c{,a}tan{,h}{f,,l} into a single templated file c{,a}tan{,h}_template.c with the exception of alpha.
* Convert _Complex sine functions to generated codePaul E. Murphy2016-08-198-48/+0
| | | | | Refactor s_c{,a}sin{,h}{f,,l} into a single templated macro.
* Merge common usage of mul_split functionPaul E. Murphy2016-08-1911-346/+22
| | | | | | | | | | | A number of files share identical code for the mul_split function. This moves the duplicated function mul_split into its own header, and refactors the fma usage into a single selection macro. Likewise, mul_split when used by a long double implementation is renamed mul_splitl for clarity.
* Convert _Complex cosine functions to generated codePaul E. Murphy2016-08-198-48/+0
| | | | | | This is fairly straight fowards. m68k overrides are updated to use the framework, and thus are simplified a bit.
* Get rid of array-bounds warning in __kernel_rem_pio2[f] with gcc 6.1 -O3.Stefan Liebler2016-08-182-0/+20
| | | | | | | | | | | | | | | | | | On s390x I get the following werror when build with gcc 6.1 (or current gcc head) and -O3: ../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function ‘__kernel_rem_pio2’: ../sysdeps/ieee754/dbl-64/k_rem_pio2.c:254:18: error: array subscript is below array bounds [-Werror=array-bounds] for (k = 1; iq[jk - k] == 0; k++) ~~^~~~~~~~ I get the same error with sysdeps/ieee754/flt-32/k_rem_pio2f.c. This patch adds DIAG_* macros around it. ChangeLog: * sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2): Use DIAG_*_NEEDS_COMMENT macro to get rid of array-bounds warning. * sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f): Likewise.
* ldbl-128: Remove unused sqrtl declaration in e_asinl.cPaul E. Murphy2016-08-171-1/+0
| | | | | This did not alter compilation for s390x and aarch64 targets.
* Support for type-generic libm function implementations libmPaul E. Murphy2016-08-1712-60/+87
| | | | | | | | | | | | | | | | | | | | | | | This defines a new classes of libm objects. The <func>_template.c file which is used in conjunction with the new makefile hooks to derive variants for each type supported by the target machine. The headers math-type-macros-TYPE.h are used to supply macros to a common implementation of a function in a file named FUNC_template.c and glued togethor via a generated file matching existing naming in the build directory. This has the properties of preserving the existing override mechanism and not requiring any arcane build system twiddling. Likewise, it enables machines to override these files without any additional work. I have verified the built objects for ppc64, x86_64, alpha, arm, and m68k do not change in any meaningful way with these changes using the Fedora cross toolchains. I have verified the x86_64 and ppc64 changes still run.
* Remove tacit double usage in ldbl-128Paul E. Murphy2016-08-033-3/+3
| | | | | | There is quiet truncation to double arithmetic in several files. I noticed them when building ldbl-128 in a soft-fp context. This did not change any test results.
* sparc64: add a VIS3 version of ceil, floor and truncAurelien Jarno2016-08-033-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sparc64 passes floating point values in the floating point registers. As the the generic ceil, floor and trunc functions use integer instructions, it makes sense to provide a VIS3 version consisting in the the generic version compiled with -mvis3. GCC will then use movdtox, movxtod, movwtos and movstow instructions. sparc32 passes the floating point values in the integer registers, so it doesn't make sense to do the same. Changelog: * sysdeps/ieee754/dbl-64/s_trunc.c: Avoid alias renamed. * sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c: Likewise. * sysdeps/ieee754/flt-32/s_truncf.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/Makefile [$(subdir) = math && $(have-as-vis3) = yes] (libm-sysdep_routines): Add s_ceilf-vis3, s_ceil-vis3, s_floorf-vis3, s_floor-vis3, s_truncf-vis3, s_trunc-vis3. (CFLAGS-s_ceilf-vis3.c): New. Set to -Wa,-Av9d -mvis3. (CFLAGS-s_ceil-vis3.c): Likewise. (CFLAGS-s_floorf-vis3.c): Likewise. (CFLAGS-s_floor-vis3.c): Likewise. (CFLAGS-s_truncf-vis3.c): Likewise. (CFLAGS-s_trunc-vis3.c): Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-vis3.c: New file. * sysdeps/sparc/sparc64/fpu/multiarch/s_ceil.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_ceilf-vis3.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_ceilf.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_floor-vis3.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_floor.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_floorf-vis3.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_floorf.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_trunc-vis3.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_trunc.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_truncf-vis3.c: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_truncf.c: Likewise.
* Fix cos computation for multiple precision fallback (bz #20357)Siddhesh Poyarekar2016-07-181-2/+2
| | | | | | | | | | | | | | | | | | | | During the sincos consolidation I made two mistakes, one was a logical error due to which cos(0x1.8475e5afd4481p+0) returned sin(0x1.8475e5afd4481p+0) instead. The second issue was an error in negating inputs for the correct quadrants for sine. I could not find a suitable test case for this despite running a program to search for such an input for a couple of hours. Following patch fixes both issues. Tested on x86_64. Thanks to Matt Clay for identifying the issue. [BZ #20357] * sysdeps/ieee754/dbl-64/s_sin.c (sloww): Fix up condition to call __mpsin/__mpcos and to negate values. * math/auto-libm-test-in: Add test. * math/auto-libm-test-out: Regenerate.
* Add nextup and nextdown math functionsRajalakshmi Srinivasaraghavan2016-06-168-1/+380
| | | | | | | | | | | 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 dbl-64 atan2 (sNaN, qNaN) (bug 20252).Joseph Myers2016-06-131-1/+1
| | | | | | | | | | | | | | | | | | 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.
* Fix frexp (NaN) (bug 20250).Joseph Myers2016-06-136-5/+8
| | | | | | | | | | | | | | | | | | | | | 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 ldbl-128ibm log1pl (sNaN) (bug 20234).Joseph Myers2016-06-091-1/+1
| | | | | | | | | | | | The ldbl-128ibm version of log1pl returns sNaN for sNaN input. This patch fixes it to add such inputs to themselves so that qNaN is returned in this case. Tested for powerpc. [BZ #20234] * sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Add positive infinity or NaN input to itself.
* Fix ldbl-128ibm expm1l (sNaN) (bug 20233).Joseph Myers2016-06-091-2/+2
| | | | | | | | | | | | The ldbl-128ibm version of expm1l returns sNaN for sNaN input. This patch fixes it to add such inputs to themselves so that qNaN is returned in this case. Tested for powerpc. [BZ #20233] * sysdeps/ieee754/ldbl-128ibm/s_expm1l.c (__expm1l): Add NaN input to itself.
* Fix ldbl-128 expm1l (sNaN) (bug 20232).Joseph Myers2016-06-091-2/+2
| | | | | | | | | | | | The ldbl-128 version of expm1l returns sNaN for sNaN input. This patch fixes it to add such inputs to themselves so that qNaN is returned in this case. Tested for mips64. [BZ #20232] * sysdeps/ieee754/ldbl-128/s_expm1l.c (__expm1l): Add NaN input to itself.
* Fix dbl-64 asin (sNaN) (bug 20213).Joseph Myers2016-06-061-1/+1
| | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | 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 ldbl-128ibm ceill, rintl etc. for sNaN arguments (bug 20156).Joseph Myers2016-05-275-0/+15
| | | | | | | | | | | | | | | | | | | The ldbl-128ibm implementations of ceill, floorl, roundl, truncl, rintl and nearbyintl wrongly return an sNaN when given an sNaN argument. This patch fixes them to add such an argument to itself to turn it into a quiet NaN. (The code structure means this "else" case applies to any argument which is zero or not finite; it's OK to do this in all such cases.) Tested for powerpc. [BZ #20156] * sysdeps/ieee754/ldbl-128ibm/s_ceill.c (__ceill): Add high part to itself when zero or not finite. * sysdeps/ieee754/ldbl-128ibm/s_floorl.c (__floorl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_rintl.c (__rintl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_roundl.c (__roundl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_truncl.c (__truncl): Likewise.
* Fix ldbl-128ibm sqrtl (sNaN) (bug 20153).Joseph Myers2016-05-261-5/+3
| | | | | | | | | | | | | | The ldbl-128ibm implementation of sqrtl wrongly returns an sNaN for signaling NaN arguments. This patch fixes it to quiet its argument, using the same x * x + x return for infinities and NaNs as the dbl-64 implementation uses to ensure that +Inf maps to +Inf while -Inf and NaN map to NaN. Tested for powerpc. [BZ #20153] * sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c (__ieee754_sqrtl): Return x * x + x for infinities and NaNs.
* Fix ldbl-128 j0l, j1l, y0l, y1l for sNaN argument (bug 20151).Joseph Myers2016-05-262-4/+4
| | | | | | | | | | | | | | | The ldbl-128 implementations of j0l, j1l, y0l, y1l (also used for ldbl-128ibm) return an sNaN argument unchanged. This patch fixes them to add a NaN argument to itself to quiet it before return. Tested for mips64. [BZ #20151] * sysdeps/ieee754/ldbl-128/e_j0l.c (__ieee754_j0l): Add NaN argument to itself before returning result. (__ieee754_y0l): Likewise. * sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_j1l): Likewise. (__ieee754_y1l).
* Do not raise "inexact" from generic round (bug 15479).Joseph Myers2016-05-245-56/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Do not raise "inexact" from generic floor (bug 15479).Joseph Myers2016-05-244-45/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 floor functions to align them with TS 18661-1 in this regard. Note that some architecture-specific versions may still raise "inexact", so the tests are not updated and the bug is not yet fixed. Tested for x86_64, x86 and mips64. [BZ #15479] * sysdeps/ieee754/dbl-64/s_floor.c: Do not mention "inexact" exception in comment. (huge): Remove variable. (__floor): Do not force "inexact" exception. * sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c: Do not mention "inexact" exception in comment. (huge): Remove variable. (__floor): Do not force "inexact" exception. * sysdeps/ieee754/flt-32/s_floorf.c: Do not mention "inexact" exception in comment. (huge): Remove variable. (__floorf): Do not force "inexact" exception. * sysdeps/ieee754/ldbl-128/s_floorl.c: Do not mention "inexact" exception in comment. (huge): Remove variable. (__floorl): Do not force "inexact" exception.