Commit Graph

977 Commits

Author SHA1 Message Date
Joseph Myers ad39cce0da Fix sin, sincos missing underflows (bug 16526, bug 16538).
Similar to various other bugs in this area, some sin and sincos
implementations do not raise the underflow exception for subnormal
arguments, when the result is tiny and inexact.  This patch forces the
exception in a similar way to previous fixes.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #16526]
	[BZ #16538]
	* sysdeps/ieee754/dbl-64/s_sin.c: Include <float.h>.
	(__sin): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/flt-32/k_sinf.c: Include <float.h>.
	(__kernel_sinf): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/k_sincosl.c: Include <float.h>.
	(__kernel_sincosl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/k_sinl.c: Include <float.h>.
	(__kernel_sinl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/k_sincosl.c: Include <float.h>.
	(__kernel_sincosl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/k_sinl.c: Include <float.h>.
	(__kernel_sinl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-96/k_sinl.c: Include <float.h>.
	(__kernel_sinl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/powerpc/fpu/k_sinf.c: Include <float.h>.
	(__kernel_sinf): Force underflow exception for arguments with
	small absolute value.
	* math/auto-libm-test-in: Add more tests of sin and sincos.
	* math/auto-libm-test-out: Regenerated.
2015-06-23 22:24:20 +00:00
Joseph Myers 8b1bab5ffa Fix spurious "inexact" exceptions from __kernel_standard_l (bug 18245, bug 18583).
__kernel_standard_l converts long double arguments to double for use
in SVID "struct exception".  This has special-case handling for when
that conversion would overflow or underflow but the original long
double function wouldn't.  However, it turns out that "inexact"
exceptions can be spurious here as well, when the function is exactly
determined and __kernel_standard_l is being called for a domain error.
This patch fixes this by using feholdexcept / fesetenv to avoid
exceptions from the conversion, replacing the previous special-case
logic for overflow and underflow (this covers all functions using
__kernel_standard_l, not just those that actually need a change, since
there doesn't seem to be much point in restricting things just to the
functions that mustn't get "inexact" here).

Tested for x86_64 and x86.

	[BZ #18245]
	[BZ #18583]
	* sysdeps/ieee754/k_standardl.c: Include <fenv.h>.
	(__kernel_standard_l): Use feholdexcept and fesetenv around
	conversion to double instead of special-casing overflow and
	underflow.
	* math/libm-test.inc (fmod_test_data): Add more tests.
	(remainder_test_data): Likewise.
	(sqrt_test_data): Likewise.
2015-06-23 17:26:46 +00:00
Joseph Myers b2faf4eadf Fix math/Makefile dependency on libm-test.stmp for libmvec tests.
Since the libmvec tests went in I've noticed build failures from
parallel testing in math/, when those tests start building before
libm-test.c has been fully generated.  (This only applies if libm test
sources have been modified after the original glibc build, because
otherwise libm-test.stmp was generated during the original build and
doesn't get regenerated during testing.)

Those tests depend on libm-test.stmp, but the dependency uses
$(libmvec-tests), which is set in the sysdeps Makefile fragments, and
appears before the inclusion of ../Rules, which is what includes those
fragments; thus, the dependency does not work and parallel make can
start building the vector tests too soon.  This patch moves the
dependency further down so that the required variable is defined when
the dependency is.

Tested for x86_64.

	* math/Makefile [$(PERL) != no]
	($(addprefix $(objpfx), $(addsuffix .o, $(libm-vec-tests)))): Move
	dependency on libm-test.stmp below the inclusion of Rules.
2015-06-23 16:27:25 +00:00
Joseph Myers 718d34a309 Fix csqrt spurious underflows (bug 18371).
The csqrt implementations in glibc can cause spurious underflows in
some cases as a side-effect of the scaling for large arguments (when
underflow is correct for the square root of the argument that was
scaled down to avoid overflow, but not for the original argument).
This patch arranges to avoid the underflowing intermediate computation
(eliminating a multiplication in 0.5 in the problem cases where a
subsequent scaling by 2 would follow).

Tested for x86_64 and x86 and ulps updated accordingly (only needed
for x86).

	[BZ #18371]
	* math/s_csqrt.c (__csqrt): Avoid multiplication by 0.5 where
	intermediate but not final result might underflow.
	* math/s_csqrtf.c (__csqrtf): Likewise.
	* math/s_csqrtl.c (__csqrtl): Likewise.
	* math/auto-libm-test-in: Add more tests of csqrt.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-06-23 16:01:54 +00:00
Joseph Myers b59549574e Fix exp2, exp2f spurious underflows (bug 18219).
The dbl-64 and flt-32 implementations of exp2 functions produce
spurious underflow exceptions.  The underlying reason is the same in
both cases: the computation works as (2^a - 1)*2^b + 2^b for suitably
chosen a and b, where a has small magnitude so 2^a - 1 can be computed
with a low-degree polynomial approximation, and (2^a - 1)*2^b can
underflow even when the final result does not.  This patch fixes this
by adjusting the threshold for when scaling is used to avoid
intermediate underflow so it works for any possible value of a where
the final result would not underflow.

Tested for x86_64 and x86.

	[BZ #18219]
	* sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Reduce
	threshold on absolute value of exponent for which scaling is used.
	* sysdeps/ieee754/flt-32/e_exp2f.c (__ieee754_exp2f): Likewise.
	* math/auto-libm-test-in: Add more tests of exp2.
	* math/auto-libm-test-out: Regenerated.
2015-06-23 14:35:18 +00:00
Joseph Myers 554edb23ff Fix expm1 missing underflows (bug 16353).
Similar to various other bugs in this area, some expm1 implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.

(The issue does not apply to the ldbl-* implementations or to those
for x86 / x86_64 long double.  The change to
sysdeps/ieee754/dbl-64/wordsize-64/e_cosh.c is one I missed when
previously fixing bug 16354; the bug in that implementation was
previously latent, but the expm1 fixes stopped it being latent and so
required it to be fixed to avoid spurious underflows from cosh.)

Tested for x86_64 and x86.

	[BZ #16353]
	* sysdeps/i386/fpu/s_expm1.S (dbl_min): New object.
	(__expm1): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/i386/fpu/s_expm1f.S (flt_min): New object.
	(__expm1f): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/dbl-64/s_expm1.c: Include <float.h>.
	(__expm1): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/flt-32/s_expm1f.c: Include <float.h>.
	(__expm1f): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/dbl-64/wordsize-64/e_cosh.c (__ieee754_cosh):
	Check for small arguments before calling __expm1.
	* math/auto-libm-test-in: Do not mark underflow exceptions as
	possibly missing for bug 16353.
	* math/auto-libm-test-out: Regenerated.
2015-06-22 21:06:19 +00:00
Joseph Myers cb0937b299 Fix x86_64 / x86 expm1l (-min_subnorm) result sign (bug 18569).
In the x86 / x86_64 implementations of expm1l, when expm1l's result
should underflow to 0 (argument minus the least subnormal, in some
rounding modes), it can be a zero of the wrong sign.  This patch fixes
this by returning the argument with underflow forced in that case
(this is a 1ulp error relative to the correctly rounded result of -0,
which is OK in terms of the documented accuracy goals, whereas a
result with the wrong sign never is).

Tested for x86_64 and x86.

	[BZ #18569]
	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]: Force
	underflow and return argument in case of subnormal argument.
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]:
	Likewise.
	* math/auto-libm-test-in: Add more tests of expm1.
	* math/auto-libm-test-out: Regenerated.
2015-06-21 18:43:10 +00:00
Joseph Myers 7540cfc5a8 Fix x86 / x86_64 expl, exp10l missing underflows (bug 16361).
Similar to various other bugs in this area, the x86 and x86_64
implementations of expl / exp10l can fail to produce underflow
exceptions when the unscaled result has trailing 0 bits so the scaling
down to subnormal precision is exact.  This patch fixes this by
forcing the exception in the case of tiny results.

Tested for x86_64 and x86.

	[BZ #16361]
	* sysdeps/i386/fpu/e_expl.S [!USE_AS_EXPM1L] (cmin): New object.
	[!USE_AS_EXPM1L] (IEEE754_EXPL): Force underflow exception for
	tiny results.
	* sysdeps/x86_64/fpu/e_expl.S [!USE_AS_EXPM1L] (cmin): New object.
	[!USE_AS_EXPM1L] (IEEE754_EXPL): Force underflow exception for
	tiny results.
	* math/auto-libm-test-in: Add more tests of exp and exp10.  Do not
	mark underflow exceptions as possibly missing for bug 16361.
	* math/auto-libm-test-out: Regenerated.
2015-06-21 17:48:04 +00:00
Joseph Myers 8db3cdefef Fix asinh missing underflows (bug 16350).
Similar to various other bugs in this area, some asinh implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.

Tested for x86_64, x86 and mips64.

	[BZ #16350]
	* sysdeps/i386/fpu/s_asinh.S (__asinh): Force underflow exception
	for arguments with small absolute value.
	* sysdeps/i386/fpu/s_asinhf.S (__asinhf): Likewise.
	* sysdeps/i386/fpu/s_asinhl.S (__asinhl): Likewise.
	* sysdeps/ieee754/dbl-64/s_asinh.c: Include <float.h>.
	(__asinh): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/flt-32/s_asinhf.c: Include <float.h>.
	(__asinhf): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/ldbl-128/s_asinhl.c: Include <float.h>.
	(__asinhl): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/ldbl-128ibm/s_asinhl.c: Include <float.h>.
	(__asinhl): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/ldbl-96/s_asinhl.c: Include <float.h>.
	(__asinhl): Force underflow exception for arguments with small
	absolute value.
	* math/auto-libm-test-in: Do not mark underflow exceptions as
	possibly missing for bug 16350.
	* math/auto-libm-test-out: Regenerated.
2015-06-18 23:27:41 +00:00
Joseph Myers a1ee4fd106 Remove stray spurious-underflow markings from cexp test.
I noticed that I'd left a spurious-underflow allowance behind in
auto-libm-test-in for a bug that was fixed some time ago.  This patch
removes it.

Tested for x86_64 and x86.

	* math/auto-libm-test-in: Remove spurious underflow allowance for
	tests of cexp.
	* math/auto-libm-test-out: Regenerated.
2015-06-18 20:51:17 +00:00
Andrew Senkevich a6336cc446 Vector sincosf for x86_64 and tests.
Here is implementation of vectorized sincosf containing SSE, AVX,
AVX2 and AVX512 versions according to Vector ABI
<https://groups.google.com/forum/#!topic/x86-64-abi/LmppCfN1rZ4>.

    * NEWS: Mention addition of x86_64 vector sincosf.
    * math/test-float-vlen16.h: Added wrapper for sincosf tests.
    * math/test-float-vlen4.h: Likewise.
    * math/test-float-vlen8.h: Likewise.
    * sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New symbols added.
    * sysdeps/x86/fpu/bits/math-vector.h: Added sincosf SIMD declaration.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support): Added new files.
    * sysdeps/x86_64/fpu/Versions: New versions added.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
    * sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines):
    Added build of SSE, AVX2 and AVX512 IFUNC versions.
    * sysdeps/x86_64/fpu/multiarch/svml_s_sincosf16_core.S
    * sysdeps/x86_64/fpu/multiarch/svml_s_sincosf16_core_avx512.S
    * sysdeps/x86_64/fpu/multiarch/svml_s_sincosf4_core.S
    * sysdeps/x86_64/fpu/multiarch/svml_s_sincosf4_core_sse4.S
    * sysdeps/x86_64/fpu/multiarch/svml_s_sincosf8_core.S
    * sysdeps/x86_64/fpu/multiarch/svml_s_sincosf8_core_avx2.S
    * sysdeps/x86_64/fpu/svml_s_sincosf16_core.S
    * sysdeps/x86_64/fpu/svml_s_sincosf4_core.S
    * sysdeps/x86_64/fpu/svml_s_sincosf8_core.S
    * sysdeps/x86_64/fpu/svml_s_sincosf8_core_avx.S
    * sysdeps/x86_64/fpu/svml_s_sincosf_data.S: New file.
    * sysdeps/x86_64/fpu/svml_s_sincosf_data.h: New file.
    * sysdeps/x86_64/fpu/svml_s_wrapper_impl.h: Added 3 argument wrappers.
    * sysdeps/x86_64/fpu/test-float-vlen16.c: : Vector sincosf tests.
    * sysdeps/x86_64/fpu/test-float-vlen16-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen4-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen4.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen8-avx2-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen8-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen8-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen8.c: Likewise.
2015-06-18 20:11:27 +03:00
Andrew Senkevich c9a8c526ac Vector sincos for x86_64 and tests.
Here is implementation of vectorized sincos containing SSE, AVX,
AVX2 and AVX512 versions according to Vector ABI
<https://groups.google.com/forum/#!topic/x86-64-abi/LmppCfN1rZ4>.

    * NEWS: Mention addition of x86_64 vector sincos.
    * bits/libm-simd-decl-stubs.h: Added stubs for sincos.
    * math/math.h (__MATHDECL_VEC): New macro.
    * math/bits/mathcalls.h: Added sincos declaration with __MATHDECL_VEC.
    * math/gen-libm-have-vector-test.sh: Added generation of sincos wrapper
    declaration under condition.
    * math/test-vec-loop.h (TEST_VEC_LOOP): Refactored.
    * math/test-double-vlen2.h: Added wrapper for sincos tests, reflected
    TEST_VEC_LOOP change.
    * math/test-double-vlen4.h: Likewise.
    * math/test-double-vlen8.h: Likewise.
    * math/test-float-vlen16.h: Reflected TEST_VEC_LOOP change.
    * math/test-float-vlen4.h: Likewise.
    * math/test-float-vlen8.h: Likewise.
    * sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New symbols added.
    * sysdeps/x86/fpu/bits/math-vector.h: Added sincos SIMD declaration.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support): Added new files.
    * sysdeps/x86_64/fpu/Versions: New versions added.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
    * sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines):
    Added build of SSE, AVX2 and AVX512 IFUNC versions.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sincos2_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sincos2_core_sse4.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sincos4_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sincos4_core_avx2.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sincos8_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sincos8_core_avx512.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sincos2_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sincos4_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sincos4_core_avx.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sincos8_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sincos_data.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sincos_data.h: New file.
    * sysdeps/x86_64/fpu/svml_d_wrapper_impl.h: Added wrappers for sincos.
    * sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c: Vector sincos tests.
    * sysdeps/x86_64/fpu/test-double-vlen2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8.c: Likewise.
2015-06-18 17:55:55 +03:00
Andrew Senkevich 8aa92022e2 Vector powf for x86_64 and tests.
Here is implementation of vectorized powf containing SSE, AVX,
AVX2 and AVX512 versions according to Vector ABI
<https://groups.google.com/forum/#!topic/x86-64-abi/LmppCfN1rZ4>.

    * sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New symbols added.
    * sysdeps/x86/fpu/bits/math-vector.h: Added SIMD declaration and asm
    redirections for powf.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support): Added new files.
    * sysdeps/x86_64/fpu/Versions: New versions added.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
    * sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines):
    Added build of SSE, AVX2 and AVX512 IFUNC versions.
    * sysdeps/x86_64/fpu/svml_s_wrapper_impl.h: Added 2 argument wrappers.
    * sysdeps/x86_64/fpu/multiarch/svml_s_powf16_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_s_powf16_core_avx512.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_s_powf4_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_s_powf4_core_sse4.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_s_powf8_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_s_powf8_core_avx2.S: New file.
    * sysdeps/x86_64/fpu/svml_s_powf16_core.S: New file.
    * sysdeps/x86_64/fpu/svml_s_powf4_core.S: New file.
    * sysdeps/x86_64/fpu/svml_s_powf8_core.S: New file.
    * sysdeps/x86_64/fpu/svml_s_powf8_core_avx.S: New file.
    * sysdeps/x86_64/fpu/svml_s_powf_data.S: New file.
    * sysdeps/x86_64/fpu/svml_s_powf_data.h: New file.
    * sysdeps/x86_64/fpu/test-float-vlen16-wrappers.c: Vector powf tests.
    * sysdeps/x86_64/fpu/test-float-vlen16.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen4-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen4.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen8-avx2-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen8-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen8-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-vlen8.c: Likewise.
    * math/test-float-vlen16.h: Fixed 2 argument macro.
    * math/test-float-vlen4.h: Likewise.
    * math/test-float-vlen8.h: Likewise.
    * NEWS: Mention addition of x86_64 vector powf.
2015-06-18 17:04:07 +03:00
Joseph Myers 2f3184451d Remove ldbl-128ibm variants of complex math functions.
sysdeps/ieee754/ldbl-128ibm has its own versions of cprojl, ctanhl and
ctanl.

Having its own versions, where otherwise the math/ copies are
generally used for all floating-point formats, means they are liable
to get out of sync and not benefit from bug fixes to the generic
versions.  The substantive differences (not arising from getting out
of sync and slightly different fixes for the same issues) are: long
double compat handling (also done in the ldbl-opt versions, so doesn't
require special versions for ldbl-128ibm); handling of LDBL_EPSILON
(conditionally undefined and redefined in other math/ implementations,
so doesn't justify a special version), and:

      /* __gcc_qmul does not respect -0.0 so we need the following fixup.  */
      if ((__real__ res == 0.0L) && (__real__ x == 0.0L))
        __real__ res = __real__ x;

      if ((__real__ res == 0.0L) && (__imag__ x == 0.0L))
        __imag__ res = __imag__ x;

But if that statement about __gcc_qmul was ever true for an old
version of that libgcc function, it's not the case for any GCC version
now supported to build glibc; there's explicit logic early in that
function (and similarly in __gcc_qdiv) to return an appropriately
signed zero if the product of the high parts is zero.  So this patch
adds the special LDBL_EPSILON handling to the generic functions and
removes the ldbl-128ibm versions.

Tested for powerpc32 (compared test-ldouble.out before and after the
changes; there are slight changes to results for ctanl / ctanhl,
arising from divergence of the implementations, but nothing that
affects the overall nature of the issues shown by the testsuite, and
in particular nothing related to signs of zero resutls).

	* math/s_ctanhl.c [LDBL_MANT_DIG == 106] (LDBL_EPSILON): Undefine
	and redefine.
	* math/s_ctanl.c [LDBL_MANT_DIG == 106] (LDBL_EPSILON): Undefine
	and redefine.
	* sysdeps/ieee754/ldbl-128ibm/s_cprojl.c: Remove file.
	* sysdeps/ieee754/ldbl-128ibm/s_ctanhl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_ctanl.c: Likewise.
2015-06-17 21:20:15 +00:00
Andrew Senkevich c10b9b13f7 Vector pow for x86_64 and tests.
Here is implementation of vectorized pow containing SSE, AVX,
AVX2 and AVX512 versions according to Vector ABI
<https://groups.google.com/forum/#!topic/x86-64-abi/LmppCfN1rZ4>.

  * bits/libm-simd-decl-stubs.h: Added stubs for pow.
    * math/bits/mathcalls.h: Added pow declaration with __MATHCALL_VEC.
    * sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New versions added.
    * sysdeps/x86/fpu/bits/math-vector.h: Added SIMD declaration and asm
    redirections for pow.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support): Added new files.
    * sysdeps/x86_64/fpu/Versions: New versions added.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
    * sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines): Added
    build of SSE, AVX2 and AVX512 IFUNC versions.
    * sysdeps/x86_64/fpu/svml_d_wrapper_impl.h: Added 2 argument wrappers.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow2_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow2_core_sse4.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow4_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow4_core_avx2.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow8_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow8_core_avx512.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow2_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow4_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow4_core_avx.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow8_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow_data.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow_data.h: New file.
    * sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c: Added vector pow test.
    * sysdeps/x86_64/fpu/test-double-vlen2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8.c: Likewise.
    * NEWS: Mention addition of x86_64 vector pow.
2015-06-17 16:22:26 +03:00
Andrew Senkevich 9c02f663f6 Vector exp for x86_64 and tests.
Here is implementation of vectorized exp containing SSE, AVX,
AVX2 and AVX512 versions according to Vector ABI
<https://groups.google.com/forum/#!topic/x86-64-abi/LmppCfN1rZ4>.

    * bits/libm-simd-decl-stubs.h: Added stubs for exp.
    * math/bits/mathcalls.h: Added exp declaration with __MATHCALL_VEC.
    * sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New versions added.
    * sysdeps/x86/fpu/bits/math-vector.h: Added SIMD declaration and asm
    redirections for exp.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support): Added new files.
    * sysdeps/x86_64/fpu/Versions: New versions added.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
    * sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines): Added
    build of SSE, AVX2 and AVX512 IFUNC versions.
    * sysdeps/x86_64/fpu/multiarch/svml_d_exp2_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_exp2_core_sse4.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_exp4_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_exp4_core_avx2.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_exp8_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_exp8_core_avx512.S: New file.
    * sysdeps/x86_64/fpu/svml_d_exp2_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_exp4_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_exp4_core_avx.S: New file.
    * sysdeps/x86_64/fpu/svml_d_exp8_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_exp_data.S: New file.
    * sysdeps/x86_64/fpu/svml_d_exp_data.h: New file.
    * sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c: Added vector exp test.
    * sysdeps/x86_64/fpu/test-double-vlen2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8.c: Likewise.
    * NEWS: Mention addition of x86_64 vector exp.
2015-06-17 15:58:05 +03:00
Andrew Senkevich 6af25acc7b Vector log for x86_64 and tests.
Here is implementation of vectorized log containing SSE, AVX,
AVX2 and AVX512 versions according to Vector ABI
<https://groups.google.com/forum/#!topic/x86-64-abi/LmppCfN1rZ4>.

    * bits/libm-simd-decl-stubs.h: Added stubs for log.
    * math/bits/mathcalls.h: Added log declaration with __MATHCALL_VEC.
    * sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New versions added.
    * sysdeps/x86/fpu/bits/math-vector.h: Added SIMD declaration and asm
    redirections for log.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support): Added new files.
    * sysdeps/x86_64/fpu/Versions: New versions added.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
    * sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines): Added
    build of SSE, AVX2 and AVX512 IFUNC versions.
    * sysdeps/x86_64/fpu/multiarch/svml_d_log2_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_log2_core_sse4.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_log4_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_log4_core_avx2.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_log8_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_log8_core_avx512.S: New file.
    * sysdeps/x86_64/fpu/svml_d_log2_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_log4_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_log4_core_avx.S: New file.
    * sysdeps/x86_64/fpu/svml_d_log8_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_log_data.S: New file.
    * sysdeps/x86_64/fpu/svml_d_log_data.h: New file.
    * sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c: Added vector log test.
    * sysdeps/x86_64/fpu/test-double-vlen2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8.c: Likewise.
    * NEWS: Mention addition of x86_64 vector log.
2015-06-17 15:38:29 +03:00
Andrew Senkevich 4b9c2b707b Vector sin for x86_64 and tests.
Here is implementation of vectorized sin containing SSE, AVX,
AVX2 and AVX512 versions according to Vector ABI
<https://groups.google.com/forum/#!topic/x86-64-abi/LmppCfN1rZ4>.

    * bits/libm-simd-decl-stubs.h: Added stubs for sin.
    * math/bits/mathcalls.h: Added sin declaration with __MATHCALL_VEC.
    * sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New versions added.
    * sysdeps/x86/fpu/bits/math-vector.h: SIMD declaration for sin.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support): Added new files.
    * sysdeps/x86_64/fpu/Versions: New versions added.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
    * sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines): Added
    build of SSE, AVX2 and AVX512 IFUNC versions.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sin2_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sin2_core_sse4.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sin4_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sin4_core_avx2.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sin8_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_sin8_core_avx512.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sin2_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sin4_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sin4_core_avx.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sin8_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sin_data.S: New file.
    * sysdeps/x86_64/fpu/svml_d_sin_data.h: New file.
    * sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c: Added vector sin test.
    * sysdeps/x86_64/fpu/test-double-vlen2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8.c: Likewise.
    * NEWS: Mention addition of x86_64 vector sin.
2015-06-11 17:12:38 +03:00
Andrew Senkevich 2a523216d5 This patch adds vector cosf tests.
* math/Makefile: Added CFLAGS for new tests.
    * math/test-float-vlen16.h: New file.
    * math/test-float-vlen4.h: New file.
    * math/test-float-vlen8.h: New file.
    * math/test-double-vlen2.h: Fixed 2 argument macro and comment.
    * sysdeps/x86_64/fpu/Makefile: Added new tests and variables.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
    * sysdeps/x86_64/fpu/test-float-vlen16-wrappers.c: New file.
    * sysdeps/x86_64/fpu/test-float-vlen16.c: New file.
    * sysdeps/x86_64/fpu/test-float-vlen4-wrappers.c: New file.
    * sysdeps/x86_64/fpu/test-float-vlen4.c: New file.
    * sysdeps/x86_64/fpu/test-float-vlen8-avx2-wrappers.c: New file.
    * sysdeps/x86_64/fpu/test-float-vlen8-avx2.c: New file.
    * sysdeps/x86_64/fpu/test-float-vlen8-wrappers.c: New file.
    * sysdeps/x86_64/fpu/test-float-vlen8.c: New file.
2015-06-09 18:32:42 +03:00
Andrew Senkevich 24a2718f59 Addition of testing infrastructure for vector math functions.
We test vector math functions using scalar tests infrastructure with
help of special wrappers from scalar versions to vector ones. Wrapper
implemented using platform specific vector types and placed in separate
file for compilation with architecture specific options, main part of
test has no such options. With help of system of definitions unfolding
of which is drived from test code we have wrapper called in individual
testing function instead of scalar function. Also system of definitions
includes generated during make check header math/libm-have-vector-test.h
with series of conditional definitions which help to avoid build fails
for functions having no vector versions; runtime architecture check
to prevent runtime fails of test run on inappropriate hardware.

    * math/Makefile: Added rules for vector tests.
    * math/gen-libm-have-vector-test.sh: Added generation of wrapper
    declaration under condition.
    * math/test-double-vlen2.h: New file.
    * math/test-double-vlen4.h: New file.
    * math/test-double-vlen8.h: New file.
    * math/test-vec-loop.h: Added initialization macro.
    * sysdeps/x86_64/fpu/Makefile: Added variables for vector tests.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenarated.
    * sysdeps/x86_64/fpu/math-tests-arch.h: New file.
    * sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c: New file.
    * sysdeps/x86_64/fpu/test-double-vlen2.c: New file.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2-wrappers.c: New file.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: New file.
    * sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c: New file.
    * sysdeps/x86_64/fpu/test-double-vlen4.c: New file.
    * sysdeps/x86_64/fpu/test-double-vlen8-wrappers.c: New file.
    * sysdeps/x86_64/fpu/test-double-vlen8.c: New file.
2015-06-09 14:51:52 +03:00
Andrew Senkevich 2193311288 Start of series of patches with x86_64 vector math functions.
Here is implementation of cos containing SSE, AVX, AVX2 and AVX512
versions according to Vector ABI which had been discussed in
<https://groups.google.com/forum/#!topic/x86-64-abi/LmppCfN1rZ4>.

Vector math library build and ABI testing enabled by default for x86_64.

    * sysdeps/x86_64/fpu/Makefile: New file.
    * sysdeps/x86_64/fpu/Versions: New file.
    * sysdeps/x86_64/fpu/svml_d_cos_data.S: New file.
    * sysdeps/x86_64/fpu/svml_d_cos_data.h: New file.
    * sysdeps/x86_64/fpu/svml_d_cos2_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_cos4_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_cos4_core_avx.S: New file.
    * sysdeps/x86_64/fpu/svml_d_cos8_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_wrapper_impl.h: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_cos2_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_cos2_core_sse4.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_cos4_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_cos4_core_avx2.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_cos8_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_cos8_core_avx512.S: New file.
    * sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines): Added
    build of SSE, AVX2 and AVX512 IFUNC versions.
    * sysdeps/x86/fpu/bits/math-vector.h: Added SIMD declaration for cos.
    * math/bits/mathcalls.h: Added cos declaration with __MATHCALL_VEC.
    * sysdeps/x86_64/configure.ac: Options for libmvec build.
    * sysdeps/x86_64/configure: Regenerated.
    * sysdeps/x86_64/sysdep.h (cfi_offset_rel_rsp): New macro.
    * sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New file.
    * manual/install.texi (Configuring and compiling): Document
    --disable-mathvec.
    * INSTALL: Regenerated.
    * NEWS: Mention addition of libmvec and x86_64 vector cos.
2015-06-09 14:25:49 +03:00
Wilco Dijkstra d81f90ccd0 This patch renames all uses of __isinf*, __isnan*, __finite* and __signbit* to use standard C99 macros. This has no effect on generated code. 2015-06-03 15:41:36 +01:00
Wilco Dijkstra 5be91118f6 Add missing math_private includes. 2015-05-20 12:48:48 +00:00
Joseph Myers 3ce2232efb Fix ldbl-96 remquol (finite, Inf) (bug 18244).
ldbl-96 remquol wrongly handles the case where the first argument is
finite and the second infinite, because the check for the second
argument being a NaN fails to disregard the explicit high mantissa bit
and so wrongly interprets an infinity as being a NaN.  This patch
fixes this by masking off that bit, and improves test coverage for
both remainder and remquo (various cases were missing tests, or, as in
the case of the bug, were tested only for one of the two functions).

Tested for x86_64 and x86.

	[BZ #18244]
	* sysdeps/ieee754/ldbl-96/s_remquol.c (__remquol): Ignore explicit
	high mantissa bit when testing whether P is a NaN.
	* math/libm-test.inc (remainder_test_data): Add more tests.
	(remquo_test_data): Likewise.
2015-05-19 23:44:28 +00:00
Joseph Myers 526af54142 Fix i386 atanhl spurious underflows (bug 18049).
The i386 implementation of atanhl, for small arguments, does a
calculation that involves computing twice the square of the argument,
resulting in spurious underflows for some arguments.  This patch fixes
this by just returning the argument when its exponent is below -32,
with underflow being forced as needed for subnormal arguments.

Tested for x86 and x86_64.

	[BZ #18049]
	* sysdeps/i386/fpu/e_atanhl.S (__ieee754_atanhl): For exponents
	below -32, return the argument, with underflow if subnormal.
	* math/auto-libm-test-in: Add more tests of atanh.
	* math/auto-libm-test-out: Regenerated.
2015-05-19 23:05:22 +00:00
Joseph Myers 8020a80887 Fix atanhl missing underflows (bug 16352).
Similar to various other bugs in this area, some atanh implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.  (No change in this regard is needed
for the i386 implementation; special handling to force underflows in
these cases will only be needed there when the spurious underflows,
bug 18049, get fixed.)

Tested for x86_64, x86, powerpc and mips64.

	[BZ #16352]
	* sysdeps/i386/fpu/e_atanh.S (dbl_min): New object.
	(__ieee754_atanh): Force underflow exception for results with
	small absolute value.
	* sysdeps/i386/fpu/e_atanhf.S (flt_min): New object.
	(__ieee754_atanhf): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/dbl-64/e_atanh.c: Include <float.h>.
	(__ieee754_atanh): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/flt-32/e_atanhf.c: Include <float.h>.
	(__ieee754_atanhf): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/e_atanhl.c: Include <float.h>.
	(__ieee754_atanhl): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/e_atanhl.c: Include <float.h>.
	(__ieee754_atanhl): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-96/e_atanhl.c: Include <float.h>.
	(__ieee754_atanhl): Force underflow exception for results with
	small absolute value.
	* math/auto-libm-test-in: Do not allow missing underflow
	exceptions from atanh.
	* math/auto-libm-test-out: Regenerated.
2015-05-15 22:07:57 +00:00
Joseph Myers 5a608ccc2d Fix tanf spurious underflows (bug 18221).
The flt-32 implementation of tanf produces spurious underflow
exceptions for some small arguments, through computing values on the
order of x^5.  This patch fixes this by adjusting the threshold for
returning x (or, as applicable, +/- 1/x) to 2**-13 (the next term in
the power series being x^3/3).

Tested for x86_64 and x86.

	[BZ #18221]
	* sysdeps/ieee754/flt-32/k_tanf.c (__kernel_tanf): Use 2**-13 not
	2**-28 as threshold for returning x or +/- 1/x.
	* math/auto-libm-test-in: Add more tests of tan.
	* math/auto-libm-test-out: Regenerated.
2015-05-15 17:47:29 +00:00
Joseph Myers ff069f024a Fix lgammaf spurious underflows (bug 18220).
The flt-32 implementation of lgammaf produces spurious underflow
exceptions for some large arguments, because of calculations involving
x^-2 multiplied by small constants.  This patch fixes this by
adjusting the threshold for a simpler computation to 2**26 (the error
in the simpler computation is on the order of 0.5 * log (x), for a
result on the order of x * log (x)).

Tested for x86_64 and x86.

	[BZ #18220]
	* sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Use
	2**26 not 2**58 as threshold for returning x * (log (x) - 1).
	* math/auto-libm-test-in: Add another test of lgamma.
	* math/auto-libm-test-out: Regenerated.
2015-05-15 17:21:08 +00:00
Joseph Myers fbc68f03b0 Fix erfcf spurious underflows (bug 18217).
The flt-32 implementation of erfcf produces spurious underflow
exceptions for some arguments close to 0, because of calculations
squaring the argument and then multiplying by small constants.  This
patch fixes this by adjusting the threshold for arguments for which
the result is so close to 1 that 1 - x will give the right result from
2**-56 to 2**-26.  (If 1 - x * 2/sqrt(pi) were used, the errors would be
on the order of x^3 and a much larger threshold could be used.)

Tested for x86_64 and x86.

	[BZ #18217]
	* sysdeps/ieee754/flt-32/s_erff.c (__erfcf): Use 2**-26 not 2**-56
	as threshold for returning 1 - x.
	* math/auto-libm-test-in: Add more tests of erfc.
	* math/auto-libm-test-out: Regenerated.
2015-05-15 00:16:10 +00:00
Joseph Myers 9a71f1fcf5 Fix atanf spurious underflows (bug 18196).
The sysdeps/ieee754/flt-32 version of atanf produces spurious
underflow exceptions for some large arguments, because of computations
that compute x^-4.  This patch fixes this by adjusting the threshold
for large arguments (for which +/- pi/2 can just be returned, the
correct result being roughly +/- pi/2 - 1/x) from 2^34 to 2^25.

Tested for x86_64 and x86.

	[BZ #18196]
	* sysdeps/ieee754/flt-32/s_atanf.c (__atanf): Use 2^25 not 2^34 as
	threshold for large arguments.
	* math/auto-libm-test-in: Add another test of atan.
	* math/auto-libm-test-out: Regenerated.
2015-05-14 23:51:09 +00:00
Joseph Myers 0b7a5f9201 Fix log1p missing underflows (bug 16339).
Similar to various other bugs in this area, some log1p implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.  (The ldbl-128ibm implementation
doesn't currently need any change as it already generates this
exception, albeit through code that would generate spurious exceptions
in other cases; special code for this issue will only be needed there
when fixing the spurious exceptions.)

Tested for x86_64, x86, powerpc and mips64.

	[BZ #16339]
	* sysdeps/i386/fpu/s_log1p.S (dbl_min): New object.
	(__log1p): Force underflow exception for results with small
	absolute value.
	* sysdeps/i386/fpu/s_log1pf.S (flt_min): New object.
	(__log1pf): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/dbl-64/s_log1p.c: Include <float.h>.
	(__log1p): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/flt-32/s_log1pf.c: Include <float.h>.
	(__log1pf): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/ldbl-128/s_log1pl.c: Include <float.h>.
	(__log1pl): Force underflow exception for results with small
	absolute value.
	* math/auto-libm-test-in: Do not allow missing underflow
	exceptions from log1p.
	* math/auto-libm-test-out: Regenerated.
2015-05-14 23:38:07 +00:00
Andrew Senkevich 5695d46f5d This is update for configure, build and install of vector math library.
Installation of libm.so as linker script only in case of libmvec.so build.

2015-05-14  Andrew Senkevich  <andrew.n.senkevich@gmail.com>

    * Makeconfig (rpath-dirs, all-subdirs): Added mathvec folder.
    (libmvec): New variable.
    * configure.ac: Added option for mathvec build.
    * configure: Regenerated.
    * mathvec/Depend: New file.
    * mathvec/Makefile: New file.
    * shlib-versions: Added libmvec.
    * math/Makefile: Added rule for libm.so installation.
2015-05-14 18:07:06 +03:00
Andrew Senkevich 202d48dab9 This patch adds infrastructure for addition of SIMD
declarations for math functions in math.h. Added new headers math-vector.h
(only generic version for now) and libm-simd-decl-stubs.h with empty
definitions required for proper unfolding of new macros __MATHCALL_VEC which
will be used for declaration of vector math functions.

2015-05-14  Andrew Senkevich  <andrew.senkevich@intel.com>

    * bits/math-vector.h: New file.
    * bits/libm-simd-decl-stubs.h: New header.
    * math/Makefile (headers): Added new header libm-simd-decl-stubs.h.
    * math/math.h (__MATHCALL_VEC): New macro.
2015-05-14 18:07:06 +03:00
Andrew Senkevich 58c50f06aa Last part of changes regarding to libm-test.inc: addition
of method for separation which exactly testing function needed to run with
help of generated during make check header with series of conditional
definitions.

2015-05-14  Andrew Senkevich  <andrew.senkevich@intel.com>

    * math/gen-libm-have-vector-test.sh: Script generates series of macros
    for conditions in testing functions.
    * math/Makefile: Added call of libm-have-vector-test.sh.
    * math/libm-test.inc (HAVE_VECTOR): New macros.
2015-05-14 18:07:06 +03:00
Andrew Senkevich a6cdcd75dc Refactoring of START for conditions in individual tests
and addition of macros used for runtime architecture check.

2015-05-14  Andrew Senkevich  <andrew.senkevich@intel.com>

    * math/libm-test.inc: START refactored.
    * math/test-double.c (TEST_MATHVEC): Add define.
    * math/test-float.c: Likewise.
    * math/test-idouble.c: Likewise.
    * math/test-ifloat.c: Likewise.
    * math/test-ildoubl.c: Likewise.
    * math/test-ldouble.c: Likewise.
    * sysdeps/generic/math-tests-arch.h (INIT_ARCH_EXT, CHECK_ARCH_EXT):
    New helper macros for runtime architecture check.
2015-05-14 18:07:06 +03:00
Andrew Senkevich ee9716019d This is the beginning of series of patches with addition
of vector math functions infrastructure and several x86_64 implementations.
This patch is preparatory change in libm-test.c - splitting of macros which
form name of tested functions for ability to use separate name for tested
functions and for functions used in test suite infrastructure.

2015-05-14  Andrew Senkevich  <andrew.senkevich@intel.com>

    * math/test-double.c (FUNC_TEST): New macro.
    * math/test-float.c: Likewise.
    * math/test-idouble.c: Likewise.
    * math/test-ifloat.c: Likewise.
    * math/test-ildoubl.c: Likewise.
    * math/test-ldouble.c: Likewise.
    * math/libm-test.inc: Use FUNC_TEST for name of tested functions.
2015-05-14 18:07:06 +03:00
Joseph Myers 14f36098f2 Add more tests of csqrt, lgamma, log10, sinh.
This patch adds more randomly-generated tests of various libm
functions that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of csqrt, lgamma, log10
	and sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-08 17:55:11 +00:00
Joseph Myers 471dffa12c Add more tests of acosh, atanh, cos, csqrt, erfc, sin, sincos.
This patch adds more randomly-generated tests of various libm
functions that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of acosh, atanh, cos,
	csqrt, erfc, sin and sincos.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-06 17:30:18 +00:00
Joseph Myers 31450d9a87 Add further tests of libm functions.
This patch adds more randomly-generated tests of various libm
functions that are observed to increase ulps on x86_64.  (This process
must eventually converge, when my random test generation stops finding
inputs that increase the listed ulps, except maybe for any cases
uncovered where the errors exceed the maximum allowed 9ulp error and
so indicate actual libm bugs needing fixing.)

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of acosh, atanh, clog,
	clog10, csqrt, erfc, exp2, expm1, log10, log2 and sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-05 22:59:41 +00:00
Joseph Myers 305392eaca Add more tests of libm functions.
This patch adds more randomly-generated tests of various libm
functions that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of atan, clog, clog10,
	cos, csqrt, erf, erfc, exp2, lgamma, log1p, sin, sincos, tanh and
	tgamma.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-02 21:06:33 +00:00
Joseph Myers 51e15247c3 Add more tests of tgamma.
This patch adds some randomly-generated tests of tgamma that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of tgamma.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 23:15:07 +00:00
Joseph Myers 5ffb9a53d7 Add more tests of tanh.
This patch adds some randomly-generated tests of tanh that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of tanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 23:06:44 +00:00
Joseph Myers 0957e15d0a Add more tests of tan.
This patch adds some randomly-generated tests of tan that are observed
to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of tan.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 22:54:39 +00:00
Joseph Myers 827bb5859c Add more tests of cos, sin, sincos.
This patch adds some randomly-generated tests of cos, sin and sincos
that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cos, sin and sincos.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 22:41:00 +00:00
Joseph Myers 86793ae758 Add another test of pow.
This patch adds a randomly-generated test of pow that is observed to
increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add another test of pow.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-05-01 22:31:24 +00:00
Joseph Myers 038e4be99c Add more tests of lgamma.
This patch adds some randomly-generated tests of lgamma that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of lgamma.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 22:17:19 +00:00
Joseph Myers a0d31f36aa Add more tests of log, log10, log1p, log2.
This patch adds some randomly-generated tests of log, log10, log1p and
log2 that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of log, log10, log2 and
	log1p.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 21:08:37 +00:00
Joseph Myers e1483b365d Add more tests of exp, exp10, exp2, expm1.
This patch adds some randomly-generated tests of exp, exp10, exp2 and
expm1 that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of exp, exp10, exp2 and
	expm1.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 20:33:04 +00:00
Joseph Myers c5a3a509df Add more tests of erf, erfc.
This patch adds some randomly-generated tests of erf and erfc that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of erf and erfc.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-05-01 17:49:44 +00:00
Joseph Myers 9862ab1f67 Add more tests of csqrt.
This patch adds some randomly-generated tests of csqrt that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of csqrt.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-30 22:51:29 +00:00
Joseph Myers 094fca83ee Add further tests of cosh and sinh.
This patch adds some further randomly-generated tests of cosh and sinh
that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cosh and sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-30 22:32:08 +00:00
Joseph Myers 7d0b257541 Fix ldbl-128 roundl for exponents in [31, 47] (bug 18346).
The implementation of roundl for ldbl-128 involves undefined behavior
for arguments with exponents from 31 to 47 inclusive, from the shift:

      u_int64_t i = -1ULL >> (j0 - 48);

For example, on mips64, this means roundl (0xffffffffffff.8p0L)
wrongly returns its argument, which is not an integer.  A condition
checking for exponents < 31 should actually be checking for exponents
< 48, and this patch makes it do so.  (That condition is for whether
the bit representing 0.5 is in the high 64-bit half of the
floating-point number.  The value 31 might have arisen from an
incorrect conversion of the ldbl-96 version to handle ldbl-128.)

This was originally reported as a GCC libquadmath bug
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65757>.

Tested for mips64; also tested for x86_64 and x86 to make sure the new
tests pass there.

	[BZ #18346]
	* sysdeps/ieee754/ldbl-128/s_roundl.c (__roundl): Handle all
	exponents less than 48 as cases where high part of mantissa needs
	examining to determine whether argument is integral.
	* math/libm-test.inc (round_test_data): Add more tests.
2015-04-28 17:27:02 +00:00
Wilco Dijkstra 92f2897953 Use __copysign rather than copysign. 2015-04-22 12:07:56 +00:00
Stefan Liebler de8aadd52c Set errno for log1p on pole/domain error.
According to bug 6792, errno is not set to ERANGE/EDOM
by calling log1p/log1pf/log1pl with x = -1 or x < -1.

This patch adds a wrapper which sets errno in those cases
and returns the value of the existing __log1p function.
The log1p is now an alias to the wrapper function
instead of __log1p.

The files in sysdeps are reflecting these changes.
The ia64 implementation sets errno by itself,
thus the wrapper-file is empty.

The libm-test is adjusted for log1p-tests to check errno.

	[BZ #6792]
	* math/w_log1p.c: New file.
	* math/w_log1pf.c: Likewise.
	* math/w_log1pl.c: Likewise.
	* math/Makefile (libm-calls): Add w_log1p.
	* math/s_log1pl.c (log1pl): Remove weak_alias.
	* sysdeps/i386/fpu/s_log1p.S (log1p): Likewise.
	* sysdeps/i386/fpu/s_log1pf.S (log1pf): Likewise.
	* sysdeps/i386/fpu/s_log1pl.S (log1pl): Likewise.
	* sysdeps/x86_64/fpu/s_log1pl.S (log1pl): Likewise.
	* sysdeps/ieee754/dbl-64/s_log1p.c (log1p): Likewise.
	[NO_LONG_DOUBLE] (log1pl): Likewise.
	* sysdeps/ieee754/flt-32/s_log1pf.c (log1pf): Likewise.
	* sysdeps/ieee754/ldbl-128/s_log1pl.c (log1pl): Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_log1pl.c
	(log1p): Remove long_double_symbol.
	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (log1pl): Likewise.
	* sysdeps/ieee754/ldbl-64-128/w_log1pl.c: New file.
	* sysdeps/ieee754/ldbl-128ibm/w_log1pl.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/s_log1p.c: Define empty weak_alias to
	remove weak_alias for corresponding log1p function.
	* sysdeps/m68k/m680x0/fpu/s_log1pf.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/s_log1pl.c: Likewise.
	* sysdeps/ia64/fpu/w_log1p.c: New file.
	* sysdeps/ia64/fpu/w_log1pf.c: Likewise.
	* sysdeps/ia64/fpu/w_log1pl.c: Likewise.
	* math/libm-test.inc (log1p_test_data):	Add errno expectations.
2015-04-13 21:19:27 +02:00
Joseph Myers b3c66c534f Add more tests of clog and clog10.
This patch adds some randomly-generated tests of clog and clog10 that
are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of clog and clog10.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-09 22:14:34 +00:00
Joseph Myers 787d22bce6 Add more tests of atanh.
This patch adds some randomly-generated tests of atanh that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of atanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-08 21:13:35 +00:00
Joseph Myers 024bcc5106 Add more tests of atan.
This patch adds some randomly-generated tests of atan that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of atan.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-08 21:00:03 +00:00
Joseph Myers da0cf658c6 Add more tests of cbrt.
This patch adds some randomly-generated tests of cbrt that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cbrt.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-04-08 17:56:15 +00:00
Joseph Myers 80352c01c1 Add more tests of cabs.
This patch adds some randomly-generated tests of cabs that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cabs.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-08 17:46:07 +00:00
Joseph Myers 8431838dde Fix dbl-64 atan2 in non-default rounding modes (bug 18210, bug 18211).
The dbl-64 implementation of atan2 does computations that expect to
run in round-to-nearest mode, and in other modes the errors can
accumulate to more than the maximum accepted 9ulp.  This patch makes
it use FE_TONEAREST internally, similar to other functions with such
issues.  Tests that previously produced large errors are added for
atan2 and the closely related carg, clog and clog10 functions.

Tested for x86_64 and x86 and ulps updated accordingly.

	[BZ #18210]
	[BZ #18211]
	* sysdeps/ieee754/dbl-64/e_atan2.c: Include <fenv.h>.
	(__ieee754_atan2): Set FE_TONEAREST mode for internal
	computations.
	* math/auto-libm-test-in: Add more tests of atan2, carg, clog and
	clog10.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-04-08 17:32:17 +00:00
Joseph Myers ae63c7ebed Fix dbl-64 atan in non-default rounding modes (bug 18197).
The dbl-64 implementation of atan does computations that expect to run
in round-to-nearest mode, and in other modes the errors can accumulate
to more than the maximum accepted 9ulp.  This patch makes it use
FE_TONEAREST internally, similar to other functions with such issues.

Tested for x86_64 and x86; no ulps updates needed.

	[BZ #18197]
	* sysdeps/ieee754/dbl-64/s_atan.c: Include <fenv.h>.
	(atan): Set FE_TONEAREST mode for internal computations.
	* math/auto-libm-test-in: Add more tests of atan.
	* math/auto-libm-test-out: Regenerated.
2015-04-08 17:14:12 +00:00
Richard Henderson 9e8c0381bb math/test-fenvinline: Cast fe_exc to unsigned int before printing
On Alpha and IA-64, fexcept_t is unsigned long.  But all the values
fit within an int, so the cast is ok for printing.  All other hosts
use unsigned int or unsigned short already.
2015-04-06 10:43:59 -07:00
Joseph Myers efd5b641dd Add more tests of acosh, asinh and atanh.
This patch adds some randomly-generated tests of acosh, asinh and
atanh that are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of acosh, asinh and
	atanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 22:21:20 +00:00
Joseph Myers e9b1015112 Add another test of asin.
This patch adds a randomly-generated test of asin that is observed to
increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add another test of asin.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 21:57:04 +00:00
Joseph Myers 38755f1421 Add more tests of asin.
This patch adds some randomly-generated tests of asin that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of asin.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 17:53:58 +00:00
Joseph Myers 8d6439712d Add more tests of acos.
This patch adds some randomly-generated tests of acos that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of acos.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 00:30:10 +00:00
Joseph Myers bc899ea090 Add more tests of expm1.
This patch adds some randomly-generated tests of expm1 that are
observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of expm1.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-25 00:05:13 +00:00
Joseph Myers 239ed6f309 Add more tests of cosh, sinh.
This patch adds some randomly-generated tests of cosh and sinh that
are observed to increase ulps on x86_64.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of cosh and sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-24 23:48:04 +00:00
Joseph Myers 7c84a5042f Add more tests of log2.
In testing for x86_64 on an AMD processor, I observed libm test
failures of the form:

testing long double (without inline functions)
Failure: Test: log2_downward (0x2.b7e151628aed4p+0)
Result:
 is:          1.44269504088896356633e+00   0xb.8aa3b295c17f67600000p-3
 should be:   1.44269504088896356622e+00   0xb.8aa3b295c17f67500000p-3
 difference:  1.08420217248550443400e-19   0x8.00000000000000000000p-66
 ulp       :  1.0000
 max.ulp   :  0.0000
Maximal error of `log2_downward'
 is      : 1 ulp
 accepted: 0 ulp

These issues arise because the maximum ulps when regenerating on one
processor are not the same as on another processor, so regeneration on
several processors may be needed when updating libm-test-ulps to avoid
failures for some users testing glibc - but such regeneration on
multiple processors is inconvenient.  Causes can be: on x86 and, for
x86_64, for long double, variation in results of x87 instructions for
transcendental operations between processors; on x86, variation in
compiler excess precision between compiler versions and
configurations; on any processor where the compiler may contract
expressions using fused multiply-add, variation in what contraction
occurs.

Although it's hard to be sure libm-test-ulps covers all ulps that may
be seen in any configuration for the given architecture, in practice
it helps simply to add wider test coverage to make it more likely
that, when testing on one processor, the ulps seen are the biggest
that can be seen for that function on that processor, and hopefully
they are also the biggest that can be seen for that function in other
configurations for that architecture.  Thus, this patch adds some
tests of log2 that increase the ulps I see on x86_64 on an Intel
processor, so that hopefully future from-scratch regenerations on that
processor will produce ulps big enough not to have errors from testing
on AMD processors.  These tests were found by randomly generating
inputs and seeing what produced ulps larger than those currently in
libm-test-ulps.  Of course such increases also improve the accuracy of
the empirical table of known ulps generated from libm-test-ulps files
that goes in the manual.

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add more tests of log2.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-03-24 23:06:28 +00:00
Joseph Myers 6411f81da9 Add test for bug 18104.
[BZ #18104]
	* math/auto-libm-test-in: Add another test of pow.
	* math/auto-libm-test-out: Regenerated.
2015-03-10 17:53:40 +00:00
Adhemerval Zanella 85b290451e powerpc: Fix inline feraiseexcept, feclearexcept macros
This patch fixes the inline feraiseexcept and feclearexcept macros for
powerpc by casting the input argument to integer before operation on it.

It fixes BZ#17776.
2015-03-03 10:01:49 -05:00
Joseph Myers 2ca725c594 Fix ldbl-96, ldbl-128ibm atanhl inaccuracy (bug 18046, bug 18047).
The threshold in ldbl-96 atanhl for when to return the argument,
0x1p-28, is a bit too big, and that in ldbl-128ibm atanhl is much too
big (the relevant condition being x^3/3 being < 0.5ulp of x),
resulting in errors a bit above the limits of those considered
acceptable in glibc in the ldbl-96 case, and in large errors in the
ldbl-128ibm case.  This patch changes those implementations to use
more appropriate thresholds and adds tests around the thresholds for
various formats.

Tested for x86_64, x86 and powerpc.  x86_64 and x86 ulps updated
accordingly.

	[BZ #18046]
	[BZ #18047]
	* sysdeps/ieee754/ldbl-128ibm/e_atanhl.c (__ieee754_atanhl): Use
	0x1p-56L as threshold for just returning the argument.
	* sysdeps/ieee754/ldbl-96/e_atanhl.c (__ieee754_atanhl): Use
	0x1p-32L as threshold for just returning the argument.
	* math/auto-libm-test-in: Add more tests of atanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulp: Likewise.
2015-02-27 17:48:37 +00:00
Joseph Myers 1d9ab20c14 Fix ldbl-128/ldbl-128ibm acosl inaccuracy (bug 18038, bug 18039).
The ldbl-128 and ldbl-128ibm implementations of acosl have similar
bugs, using a threshold of 0x1p-57L to determine when they just return
pi/2.  Since the result pi/2 - asinl (x) is roughly pi/2 - x for small
x, the relevant cut-off is actually x being < 0.5ulp of 1.  This patch
fixes the implementations to use that cut-off and adds tests of small
acos arguments.

Tested for powerpc and mips64.  Also tested for x86_64 and x86; no
ulps updates needed.

	[BZ #18038]
	[BZ #18039]
	* sysdeps/ieee754/ldbl-128/e_acosl.c (__ieee754_acosl): Only
	return pi/2 for arguments below 0x1p-113L.
	* sysdeps/ieee754/ldbl-128ibm/e_acosl.c (__ieee754_acosl): Only
	return pi/2 for arguments below 0x1p-106L.
	* math/auto-libm-test-in: Add more tests of acos.
	* math/auto-libm-test-out: Regenerated.
2015-02-26 21:06:34 +00:00
Joseph Myers ec0ce0d3be Fix asin missing underflows (bug 16351).
Similar to various other bugs in this area, some asin implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.

Tested for x86_64, x86, powerpc and mips64.

	[BZ #16351]
	* sysdeps/i386/fpu/e_asin.S (dbl_min): New object.
	(MO): New macro.
	(__ieee754_asin): Force underflow exception for results with small
	absolute value.
	* sysdeps/i386/fpu/e_asinf.S (flt_min): New object.
	(MO): New macro.
	(__ieee754_asinf): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/dbl-64/e_asin.c: Include <float.h> and <math.h>.
	(__ieee754_asin): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/flt-32/e_asinf.c: Include <float.h>.
	(__ieee754_asinf): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/e_asinl.c: Include <float.h>.
	(__ieee754_asinl): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/e_asinl.c: Include <float.h>.
	(__ieee754_asinl): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/ldbl-96/e_asinl.c: Include <float.h>.
	(__ieee754_asinl): Force underflow exception for results with
	small absolute value.
	* sysdeps/x86_64/fpu/multiarch/e_asin.c [HAVE_FMA4_SUPPORT]:
	Include <math.h>.
	* math/auto-libm-test-in: Do not mark underflow exceptions as
	possibly missing for bug 16351.
	* math/auto-libm-test-out: Regenerated.
2015-02-26 17:18:54 +00:00
Joseph Myers 380bd0fd24 Fix ldbl-128ibm logbl near powers of 2 (bug 18030).
The ldbl-128ibm implementation of logbl produces incorrect results
when the high part of the argument is a power of 2 and the low part a
nonzero number with the opposite sign (and so the returned exponent
should be 1 less than that of the high part).  For example, logbl
(0x1.ffffffffffffffp1L) returns 2 but should return 1.  (This is
similar to (fixed) bug 16740 for frexpl, and (fixed) bug 18029 for
ilogbl.)  This patch adds checks for that case.

Tested for powerpc.

	[BZ #18030]
	* sysdeps/ieee754/ldbl-128ibm/s_logbl.c (__logbl): Adjust exponent
	of power of 2 down when low part has opposite sign.
	* math/libm-test.inc (logb_test_data): Add more tests.
2015-02-26 15:14:58 +00:00
Joseph Myers 524ae9ea2e Fix ldbl-128ibm ilogbl near powers of 2 (bug 18029).
The ldbl-128ibm implementation of ilogbl produces incorrect results
when the high part of the argument is a power of 2 and the low part a
nonzero number with the opposite sign (and so the returned exponent
should be 1 less than that of the high part).  For example, ilogbl
(0x1.ffffffffffffffp1L) returns 2 but should return 1.  (This is
similar to (fixed) bug 16740 for frexpl, and bug 18030 for logbl.)
This patch adds checks for that case.

Tested for powerpc.

	[BZ #18029]
	* sysdeps/ieee754/ldbl-128ibm/e_ilogbl.c (__ieee754_ilogbl):
	Adjust exponent of power of 2 down when low part has opposite
	sign.
	* math/libm-test.inc (ilogb_test_data): Add more tests.
2015-02-26 12:57:21 +00:00
Joseph Myers 137cef7d43 Fix ldbl-128ibm asinhl inaccuracy (bug 18020).
The ldbl-128ibm implementation of asinhl uses cut-offs of 0x1p28 and
0x1p-29 to determine when to use simpler formulas that avoid possible
overflow / underflow.  Both those cut-offs are inappropriate for this
format, resulting in large errors.  This patch changes the code to use
more appropriate cut-offs of 0x1p56 and 0x1p-56, adding tests around
the cut-offs for various floating-point formats.

Tested for powerpc.  Also tested for x86_64 and x86 and updated ulps.

	[BZ #18020]
	* sysdeps/ieee754/ldbl-128ibm/s_asinhl.c (__asinhl): Use 2**56 and
	2**-56 not 2**28 and 2**-29 as thresholds for simpler formulas.
	* math/auto-libm-test-in: Add more tests of asinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-02-25 11:13:41 +00:00
Joseph Myers 440169d681 Fix ldbl-128ibm acoshl inaccuracy (bug 18019).
The ldbl-128ibm implementation of acoshl uses a cut-off of 0x1p28 to
determine when to use log(x) + log(2) as a formula.  That cut-off is
too small for this format, resulting in large errors.  This patch
changes it to a more appropriate cut-off of 0x1p56, adding tests
around the cut-offs for various floating-point formats.

Tested for powerpc.  Also tested for x86_64 and x86 and updated ulps.

	[BZ #18019]
	* sysdeps/ieee754/ldbl-128ibm/e_acoshl.c (__ieee754_acoshl): Use
	2**56 not 2**28 as threshold for log (2x) formula.
	* math/auto-libm-test-in: Add more tests of acosh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-02-25 00:01:15 +00:00
Joseph Myers 9438b237ab Fix x86/x86_64 scalb (qNaN, -Inf) (bug 16783).
Various x86 / x86_64 versions of scalb / scalbf / scalbl produce
spurious "invalid" exceptions for (qNaN, -Inf) arguments, because this
is wrongly handled like (+/-Inf, -Inf) which *should* raise such an
exception.  (In fact the NaN case of the code determining whether to
quietly return a zero or a NaN for second argument -Inf was
accidentally dead since the code had been made to return a NaN with
exception.)  This patch fixes the code to do the proper test for an
infinity as distinct from a NaN.

(Since the existing code does nothing to distinguish qNaNs and sNaNs
here, this patch doesn't either.  If in future we systematically
implement proper sNaN semantics following TS 18661-1:2014, there will
be lots of bugs to address - Thomas found lots of issues with his
patch <https://sourceware.org/ml/libc-ports/2013-04/msg00008.html> to
add SNaN tests (which never went in and would now require significant
reworking).)

Tested for x86_64 and x86.  Committed.

	[BZ #16783]
	* sysdeps/i386/fpu/e_scalb.S (__ieee754_scalb): Do not handle
	arguments (NaN, -Inf) the same as (+/-Inf, -Inf).
	* sysdeps/i386/fpu/e_scalbf.S (__ieee754_scalbf): Likewise.
	* sysdeps/i386/fpu/e_scalbl.S (__ieee754_scalbl): Likewise.
	* sysdeps/x86_64/fpu/e_scalbl.S (__ieee754_scalbl): Likewise.
	* math/libm-test.inc (scalb_test_data): Add more tests.
2015-02-24 17:30:02 +00:00
Chung-Lin Tang 9529611240 Adjust timeouts for some tests, to accommodate slow processors,
often without FPUs.
2015-02-22 01:05:02 -08:00
Joseph Myers 4629c866ad Fix atan / atan2 missing underflows (bug 15319).
This patch fixes bug 15319, missing underflows from atan / atan2 when
the result of atan is very close to its small argument (or that of
atan2 is very close to the ratio of its arguments, which may be an
exact division).

The usual approach of doing an underflowing computation if the
computed result is subnormal is followed.  For 32-bit x86, there are
extra complications: the inline __ieee754_atan2 in bits/mathinline.h
needs to be disabled for float and double because other libm functions
using it generally rely on getting proper underflow exceptions from
it, while the out-of-line functions have to remove excess range and
precision from the underflowing result so as to return an exact 0 in
the case where errno should be set for underflow to 0.  (The failures
I saw without that are similar to those Carlos reported for other
functions, where I haven't seen a response to
<https://sourceware.org/ml/libc-alpha/2015-01/msg00485.html>
confirming if my diagnosis is correct.  Arguably all libm functions
with float and double returns should remove excess range and
precision, but that's a separate matter.)

The x86_64 long double case reported in a comment in bug 15319 is not
a bug (it's an argument of LDBL_MIN, and x86_64 is an after-rounding
architecture so the correct IEEE result is not to raise underflow in
the given rounding mode, in addition to treating the result as an
exact LDBL_MIN being within the newly clarified documentation of
accuracy goals).  I'm presuming that the fpatan instruction can be
trusted to raise appropriate exceptions when the (long double) result
underflows (after rounding) and so no changes are needed for x86 /
x86_64 long double functions here; empirically this is the case for
the cases covered in the testsuite, on my system.

Tested for x86_64, x86, powerpc and mips64.  Only 32-bit x86 needs
ulps updates (for the changes to inlines meaning some functions no
longer get excess precision from their __ieee754_atan2* calls).

	[BZ #15319]
	* sysdeps/i386/fpu/e_atan2.S (dbl_min): New object.
	(MO): New macro.
	(__ieee754_atan2): For results with small absolute value, force
	underflow exception and remove excess range and precision from
	return value.
	* sysdeps/i386/fpu/e_atan2f.S (flt_min): New object.
	(MO): New macro.
	(__ieee754_atan2f): For results with small absolute value, force
	underflow exception and remove excess range and precision from
	return value.
	* sysdeps/i386/fpu/s_atan.S (dbl_min): New object.
	(MO): New macro.
	(__atan): For results with small absolute value, force underflow
	exception and remove excess range and precision from return value.
	* sysdeps/i386/fpu/s_atanf.S (flt_min): New object.
	(MO): New macro.
	(__atanf): For results with small absolute value, force underflow
	exception and remove excess range and precision from return value.
	* sysdeps/ieee754/dbl-64/e_atan2.c: Include <float.h> and
	<math.h>.
	(__ieee754_atan2): Force underflow exception for results with
	small absolute value.
	* sysdeps/ieee754/dbl-64/s_atan.c: Include <float.h> and
	<math_private.h>.
	(atan): Force underflow exception for results with small absolute
	value.
	* sysdeps/ieee754/flt-32/s_atanf.c: Include <float.h>.
	(__atanf): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/ldbl-128/s_atanl.c: Include <float.h> and
	<math.h>.
	(__atanl): Force underflow exception for results with small
	absolute value.
	* sysdeps/ieee754/ldbl-128ibm/s_atanl.c: Include <float.h>.
	(__atanl): Force underflow exception for results with small
	absolute value.
	* sysdeps/x86/fpu/bits/mathinline.h
	[!__SSE2_MATH__ && !__x86_64__ && __LIBC_INTERNAL_MATH_INLINES]
	(__ieee754_atan2): Only define inline for long double.
	* sysdeps/x86_64/fpu/multiarch/e_atan2.c
	[HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Include <math.h>.
	* math/auto-libm-test-in: Do not mark underflow exceptions as
	possibly missing for bug 15319.  Add more tests of atan2.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (casin_test_data): Do not mark underflow
	exceptions as possibly missing for bug 15319.
	(casinh_test_data): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-02-18 21:10:49 +00:00
Joseph Myers ce8fc784e6 Fix sign of remquo zero remainder in round-downward mode (bug 17987).
Various remquo implementations produce a zero remainder with the wrong
sign (a zero remainder should always have the sign of the first
argument, as specified in IEEE 754) in round-downward mode, resulting
from the sign of 0 - 0.  This patch checks for zero results and fixes
their sign accordingly.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #17987]
	* sysdeps/ieee754/dbl-64/s_remquo.c (__remquo): Ensure sign of
	zero result does not depend on the sign resulting from
	subtraction.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo):
	Likewise.
	* sysdeps/ieee754/flt-32/s_remquof.c (__remquof): Likewise.
	* sysdeps/ieee754/ldbl-128/s_remquol.c (__remquol): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_remquol.c (__remquol): Likewise.
	* sysdeps/ieee754/ldbl-96/s_remquol.c (__remquol): Likewise.
	* math/libm-test.inc (remquo_test_data): Add more tests.
2015-02-17 00:41:50 +00:00
Joseph Myers a820f9b3c0 Fix remquo spurious overflows (bug 17978).
Various remquo implementations, when computing the last three bits of
the quotient, have spurious overflows when 4 times the second argument
to remquo overflows.  These overflows can in turn cause bad results in
rounding modes where that overflow results in a finite value.  This
patch adds tests to avoid the problem multiplications in cases where
they would overflow, similar to those that control an earlier
multiplication by 8.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #17978]
	* sysdeps/ieee754/dbl-64/s_remquo.c (__remquo): Do not form
	products 4 * y and 2 * y where those would overflow.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo):
	Likewise.
	* sysdeps/ieee754/flt-32/s_remquof.c (__remquof): Likewise.
	* sysdeps/ieee754/ldbl-128/s_remquol.c (__remquol): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_remquol.c (__remquol): Likewise.
	* sysdeps/ieee754/ldbl-96/s_remquol.c (__remquol): Likewise.
	* math/libm-test.inc (remquo_test_data): Add more tests.
2015-02-16 22:38:28 +00:00
Joseph Myers d9afe48d55 Fix dbl-64/wordsize-64 remquo (bug 17569).
The dbl-64/wordsize-64 remquo implementation follows similar logic to
various other implementations, but where that logic computes some
absolute values, it wrongly uses a previously computed bit-pattern for
the absolute value of the first argument, where actually it needs the
absolute value of the first argument mod 8 times the second.  This
patch fixes it to compute the correct absolute value.

The integer quotient result of remquo is only specified mod 8
(including its sign); architecture-specific versions may well vary in
what results they give for higher bits of that result (and indeed bug
17569 gives an example correct result from __builtin_remquo giving 9
for that result, where the particular glibc implementation used in
that bug report would give 1 after this fix).  Thus, this patch adapts
the tests of remquo to test that result only mod 8, to allow for such
variation when tests with higher quotient are included.

Tested for x86_64 and x86.

	[BZ #17569]
	* sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo):
	Compute absolute value of x as modified by fmod, not original
	value of x.
	* math/libm-test.inc (RUN_TEST_ffI_f1): Rename to
	RUN_TEST_ffI_f1_mod8.  Check extra return value mod 8.
	(RUN_TEST_LOOP_ffI_f1): Rename to RUN_TEST_LOOP_ffI_f1_mod8.  Call
	RUN_TEST_ffI_f1_mod8.
	(remquo_test_data): Add more tests.
2015-02-13 21:54:44 +00:00
Joseph Myers 03d95bd483 Fix exp2 spurious underflows (bug 16560).
This patch fixes the remaining part of bug 16560, spurious underflows
from exp2 of arguments close to 0 (when the result is close to 1, so
should not underflow), by just using 1+x instead of a more complicated
calculation when the argument is sufficiently small.

Tested for x86_64, x86 and mips64.

	[BZ #16560]
	* math/e_exp2l.c [LDBL_MANT_DIG == 106] (LDBL_EPSILON): Undefine
	and redefine.
	(__ieee754_exp2l): Do not multiply small fractional parts by
	M_LN2l.
	* sysdeps/i386/fpu/e_exp2l.S (__ieee754_exp2l): Just add 1 to
	small argument.
	* sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Likewise.
	* sysdeps/ieee754/flt-32/e_exp2f.c (__ieee754_exp2f): Likewise.
	* sysdeps/x86_64/fpu/e_exp2l.S (__ieee754_exp2l): Likewise.
	* math/auto-libm-test-in: Add more tests of exp2.
	* math/auto-libm-test-out: Regenerated.
2015-02-12 19:02:45 +00:00
Joseph Myers d435569cd6 Fix sincos errno setting (bug 15467).
This patch makes sincos set errno to EDOM when passed an infinity,
similarly to sin and cos.

Tested for x86_64, x86, powerpc and mips64.  I don't know if the
architecture-specific implementations for ia64 and m68k might need
corresponding fixes.

2015-02-11  Joseph Myers  <joseph@codesourcery.com>

	[BZ #15467]
	* sysdeps/ieee754/dbl-64/s_sincos.c: Include <errno.h>.
	(__sincos): Set errno to EDOM for infinite argument.
	* sysdeps/ieee754/flt-32/s_sincosf.c: Include <errno.h>.
	(SINCOSF_FUNC): Set errno to EDOM for infinite argument.
	* sysdeps/ieee754/ldbl-128/s_sincosl.c: Include <errno.h>.
	(__sincosl): Set errno to EDOM for infinite argument.
	* sysdeps/ieee754/ldbl-128ibm/s_sincosl.c: Include <errno.h>.
	(__sincosl): Set errno to EDOM for infinite argument.
	* sysdeps/ieee754/ldbl-96/s_sincosl.c: Include <errno.h>.
	(__sincosl): Set errno to EDOM for infinite argument.
	* math/libm-test.inc (sincos_test_data): Test errno setting.
2015-02-11 23:17:25 +00:00
Roland McGrath 92b67e8def Clean up math/test-snan. 2015-02-10 13:55:29 -08:00
Joseph Myers 1c7a4a51a3 soft-fp: Fix _FP_FMA when product is zero and third argument is finite (bug 17932).
soft-fp's _FP_FMA fails to set the result's exponent for cases where
the result of the multiplication is 0, yielding incorrect (arbitrary,
depending on uninitialized values) results for those cases.  This
affects libm for architectures using soft-fp to implement fma.  This
patch adds the exponent setting and tests for this case.

Tested for ARM soft-float (which uses soft-fp fma), x86_64 and x86 (to
verify not introducing new libm test failures there).

(This bug showed up in testing my patch to move the Linux kernel to
current soft-fp.  math/Makefile has "override CFLAGS +=
-Wno-uninitialized" which would have stopped compiler warnings from
showing up this problem, although I wouldn't be surprised if removing
that shows spurious warnings from this code, if the compiler fails to
follow that various cases where the exponent is uninitialized don't
need it initialized because the class is set to a value meaning the
uninitialized exponent isn't used.)

	[BZ #17932]
	* soft-fp/op-common.h (_FP_FMA): Set exponent of result in case
	where multiplication results in zero and third argument is finite
	and nonzero.
	* math/auto-libm-test-in: Add more tests of fma.
	* math/auto-libm-test-out: Regenerated.
2015-02-06 15:44:07 +00:00
Martin Sebor 527de9e4e3 Clarify math/README.libm-test. Add "How to read the test output." 2015-01-28 21:07:01 -07:00
Joseph Myers 5a9e4c09a2 Fix ldbl-96 scalblnl underflowing results (bug 17803).
The ldbl-96 implementation of scalblnl (used for x86_64 and ia64) uses
a condition k <= -63 to determine when a standard underflowing result
tiny*__copysignl(tiny,x) should be returned.  However, that condition
corresponds to values with exponent -16446 or less, and in the case of
-16446, the correct result for round-to-nearest depends on whether the
value is exactly 0x1p-16446 (half the least subnormal) or more than
that.  This patch fixes the bug by changing the condition to k <= -64
and accordingly adjusting the exponent by 64 not 63 when converting to
a normal value.

Tested for x86_64.

	[BZ #17803]
	* sysdeps/ieee754/ldbl-96/s_scalblnl.c (twom63): Rename to
	twom64.  Adjust value to 0x1p-64L.
	(__scalblnl): Only return standard underflowing result for K <=
	-64 not K <= -63; adjust exponent for underflowing result by 64
	not 63.
	* math/libm-test.inc (scalbn_test_data): Add more tests.
	(scalbln_test_data): Likewise.
2015-01-12 23:02:14 +00:00
Joseph Myers 34e93d6c76 Fix ldbl-96 scalblnl for subnormal arguments (bug 17834).
The ldbl-96 implementation of scalblnl (used for x86_64 and ia64) is
incorrect for subnormal arguments (this is a separate bug from bug
17803, which is about underflowing results).  There are two problems
with the adjustments of subnormal arguments: the "two63" variable
multiplied by is actually 0x1p52L not 0x1p63L, so is insufficient to
make values normal, and then GET_LDOUBLE_EXP(es,x), used to extract
the new exponent, extracts it into a variable that isn't used, while
the value taken to by the new exponent is wrongly taken from the high
part of the mantissa before the adjustment (hx).  This patch fixes
both those problems and adds appropriate tests.

Tested for x86_64.

	[BZ #17834]
	* sysdeps/ieee754/ldbl-96/s_scalblnl.c (two63): Change value to
	0x1p63L.
	(__scalblnl): Get new exponent of adjusted subnormal value from ES
	not HX.
	* math/libm-test.inc (scalbn_test_data): Add more tests.
	(scalbln_test_data): Likewise.
2015-01-12 22:34:58 +00:00
Joseph Myers 8116321f65 Fix libm feupdateenv namespace (bug 17748).
Concluding the fixes for C90 libm functions calling C99 fe* functions,
this patch fixes the case of feupdateenv by making it a weak alias for
__feupdateenv and making the affected code call __feupdateenv.

Tested for x86_64 (testsuite, and that installed stripped shared
libraries are unchanged by the patch).  Also tested for ARM
(soft-float) that the math.h linknamespace tests now pass.

	[BZ #17748]
	* include/fenv.h (__feupdateenv): Use libm_hidden_proto.
	* math/feupdateenv.c (__feupdateenv): Use libm_hidden_def.
	* sysdeps/aarch64/fpu/feupdateenv.c (feupdateenv): Rename to
	__feupdateenv and define as weak alias of __feupdateenv.  Use
	libm_hidden_weak.
	* sysdeps/alpha/fpu/feupdateenv.c (__feupdateenv): Use
	libm_hidden_def.
	* sysdeps/arm/feupdateenv.c (feupdateenv): Rename to __feupdateenv
	and define as weak alias of __feupdateenv.  Use libm_hidden_weak.
	* sysdeps/hppa/fpu/feupdateenv.c (feupdateenv): Likewise.
	* sysdeps/i386/fpu/feupdateenv.c (__feupdateenv): Use
	libm_hidden_def.
	* sysdeps/ia64/fpu/feupdateenv.c (feupdateenv): Rename to
	__feupdateenv and define as weak alias of __feupdateenv.  Use
	libm_hidden_weak.
	* sysdeps/m68k/fpu/feupdateenv.c (__feupdateenv): Use
	libm_hidden_def.
	* sysdeps/mips/fpu/feupdateenv.c (feupdateenv): Rename to
	__feupdateenv and define as weak alias of __feupdateenv.  Use
	libm_hidden_weak.
	* sysdeps/powerpc/fpu/feupdateenv.c (__feupdateenv): Use
	libm_hidden_def.
	* sysdeps/powerpc/nofpu/feupdateenv.c (__feupdateenv): Likewise.
	* sysdeps/powerpc/powerpc32/e500/nofpu/feupdateenv.c
	(__feupdateenv): Likewise.
	* sysdeps/s390/fpu/feupdateenv.c (feupdateenv): Rename to
	__feupdateenv and define as weak alias of __feupdateenv.  Use
	libm_hidden_weak.
	* sysdeps/sh/sh4/fpu/feupdateenv.c (feupdateenv): Likewise.
	* sysdeps/sparc/fpu/feupdateenv.c (__feupdateenv): Use
	libm_hidden_def.
	* sysdeps/tile/math_private.h (__feupdateenv): New inline
	function.
	* sysdeps/x86_64/fpu/feupdateenv.c (__feupdateenv): Use
	libm_hidden_def.
	* sysdeps/generic/math_private.h (default_libc_feupdateenv): Call
	__feupdateenv instead of feupdateenv.
	(default_libc_feupdateenv_test): Likewise.
	(libc_feresetround_ctx): Likewise.
2015-01-07 19:01:20 +00:00
Joseph Myers 01238691bb Fix libm fesetround namespace (bug 17748).
Continuing the fixes for C90 libm functions calling C99 fe* functions,
this patch fixes the case of fesetround by making it a weak alias of
__fesetround and making the affected code call __fesetround.  An
existing __fesetround function in fenv_libc.h for powerpc is renamed
to __fesetround_inline.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).  Also tested for ARM
(soft-float) that fesetround failures disappear from the linknamespace
test results (feupdateenv remains to be addressed to complete fixing
bug 17748).

	[BZ #17748]
	* include/fenv.h (__fesetround): Declare.  Use libm_hidden_proto.
	* math/fesetround.c (fesetround): Rename to __fesetround and
	define as weak alias of __fesetround.  Use libm_hidden_weak.
	* sysdeps/aarch64/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/alpha/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/arm/fesetround.c (fesetround): Likewise.
	* sysdeps/hppa/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/i386/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/ia64/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/m68k/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/mips/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/powerpc/fpu/fenv_libc.h (__fesetround): Rename to
	__fesetround_inline.
	* sysdeps/powerpc/fpu/fenv_private.h (libc_fesetround_ppc): Call
	__fesetround_inline instead of __fesetround.
	* sysdeps/powerpc/fpu/fesetround.c (fesetround): Rename to
	__fesetround and define as weak alias of __fesetround.  Use
	libm_hidden_weak.  Call __fesetround_inline instead of
	__fesetround.
	* sysdeps/powerpc/nofpu/fesetround.c (fesetround): Rename to
	__fesetround and define as weak alias of __fesetround.  Use
	libm_hidden_weak.
	* sysdeps/powerpc/powerpc32/e500/nofpu/fesetround.c (fesetround):
	Likewise.
	* sysdeps/s390/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/sh/sh4/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/sparc/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/tile/math_private.h (__fesetround): New inline function.
	* sysdeps/x86_64/fpu/fesetround.c (fesetround): Rename to
	__fesetround and define as weak alias of __fesetround.  Use
	libm_hidden_weak.
	* sysdeps/generic/math_private.h (default_libc_fesetround): Call
	__fesetround instead of fesetround.
	(default_libc_feholdexcept_setround): Likewise.
	(libc_feholdsetround_ctx): Likewise.
	(libc_feholdsetround_noex_ctx): Likewise.
2015-01-07 00:41:23 +00:00
Joseph Myers cd42798aef Fix libm fesetenv namespace (bug 17748).
Continuing the fixes for C90 libm functions calling C99 fe* functions,
this patch fixes the case of fesetenv by making it a weak alias of
__fesetenv and making the affected code (including various copies of
feupdateenv which also gets called from C90 functions) call
__fesetenv.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).  Also tested for ARM
(soft-float) that fesetenv failures disappear from the linknamespace
test results (fsetround and feupdateenv remain to be addressed to
complete fixing bug 17748).

	[BZ #17748]
	* include/fenv.h (__fesetenv): Use libm_hidden_proto.
	* math/fesetenv.c (__fesetenv): Use libm_hidden_def.
	* sysdeps/aarch64/fpu/fesetenv.c (fesetenv): Rename to __fesetenv
	and define as weak alias of __fesetenv.  Use libm_hidden_weak.
	* sysdeps/alpha/fpu/fesetenv.c (__fesetenv): Use libm_hidden_def.
	* sysdeps/arm/fesetenv.c (fesetenv): Rename to __fesetenv and
	define as weak alias of __fesetenv.  Use libm_hidden_weak.
	* sysdeps/hppa/fpu/fesetenv.c (fesetenv): Likewise.
	* sysdeps/i386/fpu/fesetenv.c (__fesetenv): Use libm_hidden_def.
	* sysdeps/ia64/fpu/fesetenv.c (fesetenv): Rename to __fesetenv and
	define as weak alias of __fesetenv.  Use libm_hidden_weak.
	* sysdeps/m68k/fpu/fesetenv.c (__fesetenv): Use libm_hidden_def.
	* sysdeps/mips/fpu/fesetenv.c (fesetenv): Rename to __fesetenv and
	define as weak alias of __fesetenv.  Use libm_hidden_weak.
	* sysdeps/powerpc/fpu/fesetenv.c (__fesetenv): Use
	libm_hidden_def.
	* sysdeps/powerpc/nofpu/fesetenv.c (__fesetenv): Likewise.
	* sysdeps/powerpc/powerpc32/e500/nofpu/fesetenv.c (__fesetenv):
	Likewise.
	* sysdeps/s390/fpu/fesetenv.c (fesetenv): Rename to __fesetenv and
	define as weak alias of __fesetenv.  Use libm_hidden_weak.
	* sysdeps/sh/sh4/fpu/fesetenv.c (fesetenv): Likewise.
	* sysdeps/sparc/fpu/fesetenv.c (__fesetenv): Use libm_hidden_def.
	* sysdeps/tile/math_private.h (__fesetenv): New inline function.
	* sysdeps/x86_64/fpu/fesetenv.c (fesetenv): Rename to __fesetenv
	and define as weak alias of __fesetenv.  Use libm_hidden_weak.
	* sysdeps/generic/math_private.h (default_libc_fesetenv): Use
	__fesetenv instead of fesetenv.
	(libc_feresetround_noex_ctx): Likewise.
	* sysdeps/alpha/fpu/feupdateenv.c (__feupdateenv): Likewise.
	* sysdeps/hppa/fpu/feupdateenv.c (feupdateenv): Likewise.
	* sysdeps/i386/fpu/feupdateenv.c (__feupdateenv): Likewise.
	* sysdeps/ia64/fpu/feupdateenv.c (feupdateenv): Likewise.
	* sysdeps/m68k/fpu/feupdateenv.c (__feupdateenv): Likewise.
	* sysdeps/mips/fpu/feupdateenv.c (feupdateenv): Likewise.
	* sysdeps/powerpc/nofpu/feupdateenv.c (__feupdateenv): Likewise.
	* sysdeps/powerpc/powerpc32/e500/nofpu/feupdateenv.c
	(__feupdateenv): Likewise.
	* sysdeps/s390/fpu/feupdateenv.c (feupdateenv): Likewise.
	* sysdeps/sh/sh4/fpu/feupdateenv.c (feupdateenv): Likewise.
	* sysdeps/sparc/fpu/feupdateenv.c (__feupdateenv): Likewise.
	* sysdeps/x86_64/fpu/feupdateenv.c (__feupdateenv): Likewise.
2015-01-06 23:36:20 +00:00
Andrew Senkevich 10a5e112b6 Remove duplicated -frounding-math
No need to add -frounding-math.  math-flags in Makeconfig includes
-frounding-math.

	* math/Makefile (CFLAGS-test-float.c): Remove -frounding-math.
	(CFLAGS-test-double.c): Likewise.
	(CFLAGS-test-ldouble.c): Likewise.
	(CPPFLAGS-test-ifloat.c): Likewise.
	(CPPFLAGS-test-idouble.c): Likewise.
	(CPPFLAGS-test-ildoubl.c): Likewise.
	(CFLAGS-test-test-fenv.c): Remove variable.
	(CFLAGS-test-misc.c): Likewise.
2015-01-06 06:32:03 -08:00
Joseph Myers ef9faf1385 Fix libm feholdexcept namespace (bug 17748).
Continuing the fixes for C90 libm functions calling C99 fe* functions,
this patch fixes the case of feholdexcept by making it a weak alias of
__feholdexcept and making the affected code call __feholdexcept.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).  Also tested for ARM
(soft-float) that feholdexcept failures disappear from the
linknamespace test failures (fesetenv, fsetround and feupdateenv
remain to be addressed to complete fixing bug 17748).

	[BZ #17748]
	* include/fenv.h (__feholdexcept): Declare.  Use
	libm_hidden_proto.
	* math/feholdexcpt.c (feholdexcept): Rename to __feholdexcept and
	define as weak alias of __feholdexcept.  Use libm_hidden_weak.
	* sysdeps/aarch64/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/alpha/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/arm/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/hppa/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/i386/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/ia64/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/m68k/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/mips/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/powerpc/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/powerpc/nofpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/powerpc/powerpc32/e500/nofpu/feholdexcpt.c
	(feholdexcept): Likewise.
	* sysdeps/s390/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/sh/sh4/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/sparc/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/x86_64/fpu/feholdexcpt.c (feholdexcept): Likewise.
	* sysdeps/generic/math_private.h (default_libc_feholdexcept): Use
	__feholdexcept instead of feholdexcept.
	(default_libc_feholdexcept_setround): Likewise.
2015-01-05 23:06:14 +00:00
Joseph Myers b93c2205ec Fix libm fegetround namespace (bug 17748).
Continuing the fixes for C90 libm functions calling C99 fe* functions,
this patch fixes the case of fegetround by making it a weak alias of
__fegetround and making the affected code call __fegetround.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).  Also tested for ARM
(soft-float) that fegetround failures disappear from the linknamespace
test failures (feholdexcept, fesetenv, fesetround and feupdateenv
remain to be addressed before bug 17748 is fully fixed, although this
patch may suffice to fix the failures in some cases, when the libc_fe*
functions are implemented but there is no architecture-specific sqrt
implementation in use so there were failures from fegetround used by
sqrt but no other such failures).

	[BZ #17748]
	* include/fenv.h (__fegetround): Declare.  Use libm_hidden_proto.
	* math/fegetround.c (fegetround): Rename to __fegetround and
	define as weak alias of __fegetround.  Use libm_hidden_weak.
	* sysdeps/aarch64/fpu/fegetround.c (fegetround): Likewise.
	* sysdeps/alpha/fpu/fegetround.c (fegetround): Likewise.
	* sysdeps/arm/fegetround.c (fegetround): Likewise.
	* sysdeps/hppa/fpu/fegetround.c (fegetround): Likewise.
	* sysdeps/i386/fpu/fegetround.c (fegetround): Likewise.
	* sysdeps/ia64/fpu/fegetround.c (fegetround): Likewise.
	* sysdeps/m68k/fpu/fegetround.c (fegetround): Likewise.
	* sysdeps/mips/fpu/fegetround.c (fegetround): Likewise.
	* sysdeps/powerpc/fpu/fegetround.c (fegetround): Likewise.
	Undefine after rather than before function definition; use
	parentheses around function name in definition.
	(__fegetround): Also undefine macro after function definition.
	* sysdeps/powerpc/nofpu/fegetround.c (fegetround): Rename to
	__fegetround and define as weak alias of __fegetround.  Use
	libm_hidden_weak.  Do not undefine as macro.
	* sysdeps/powerpc/powerpc32/e500/nofpu/fegetround.c (fegetround):
	Likewise.
	* sysdeps/s390/fpu/fegetround.c (fegetround): Rename to
	__fegetround and define as weak alias of __fegetround.  Use
	libm_hidden_weak.
	* sysdeps/sh/sh4/fpu/fegetround.c (fegetround): Likewise.
	* sysdeps/sparc/fpu/fegetround.c (fegetround): Likewise.
	* sysdeps/tile/math_private.h (__fegetround): New inline function.
	* sysdeps/x86_64/fpu/fegetround.c (fegetround): Rename to
	__fegetround and define as weak alias of __fegetround.  Use
	libm_hidden_weak.
	* sysdeps/ieee754/dbl-64/e_sqrt.c (__ieee754_sqrt): Use
	__fegetround instead of fegetround.
2015-01-02 20:44:42 +00:00
Joseph Myers b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Joseph Myers 73a268c759 Fix libm fegetenv namespace (bug 17748).
Some C90 libm functions call fegetenv via libc_feholdsetround*
functions in math_private.h.  This patch makes them call __fegetenv
instead, making fegetenv into a weak alias for __fegetenv as needed.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).  Also tested for ARM
(soft-float) that fegetenv failures disappear from the linknamespace
test failures (however, similar fixes will also be needed for
fegetround, feholdexcept, fesetenv, fesetround and feupdateenv before
this set of namespace issues covered by bug 17748 is fully fixed and
those linknamespace tests start passing).

	[BZ #17748]
	* include/fenv.h (__fegetenv): Use libm_hidden_proto.
	* math/fegetenv.c (__fegetenv): Use libm_hidden_def.
	* sysdeps/aarch64/fpu/fegetenv.c (fegetenv): Rename to __fegetenv
	and define as weak alias of __fegetenv.  Use libm_hidden_weak.
	* sysdeps/alpha/fpu/fegetenv.c (__fegetenv): Use libm_hidden_def.
	* sysdeps/arm/fegetenv.c (fegetenv): Rename to __fegetenv and
	define as weak alias of __fegetenv.  Use libm_hidden_weak.
	* sysdeps/hppa/fpu/fegetenv.c (fegetenv): Likewise.
	* sysdeps/i386/fpu/fegetenv.c (__fegetenv): Use libm_hidden_def.
	* sysdeps/ia64/fpu/fegetenv.c (fegetenv): Rename to __fegetenv and
	define as weak alias of __fegetenv.  Use libm_hidden_weak.
	* sysdeps/m68k/fpu/fegetenv.c (__fegetenv): Use libm_hidden_def.
	* sysdeps/mips/fpu/fegetenv.c (fegetenv): Rename to __fegetenv and
	define as weak alias of __fegetenv.  Use libm_hidden_weak.
	* sysdeps/powerpc/fpu/fegetenv.c (__fegetenv): Use
	libm_hidden_def.
	* sysdeps/powerpc/nofpu/fegetenv.c (__fegetenv): Likewise.
	* sysdeps/powerpc/powerpc32/e500/nofpu/fegetenv.c (__fegetenv):
	Likewise.
	* sysdeps/s390/fpu/fegetenv.c (fegetenv): Rename to __fegetenv and
	define as weak alias of __fegetenv.  Use libm_hidden_weak.
	* sysdeps/sh/sh4/fpu/fegetenv.c (fegetenv): Likewise.
	* sysdeps/sparc/fpu/fegetenv.c (__fegetenv): Use libm_hidden_def.
	* sysdeps/tile/math_private.h (__fegetenv): New inline function.
	* sysdeps/x86_64/fpu/fegetenv.c (fegetenv): Rename to __fegetenv
	and define as weak alias of __fegetenv.  Use libm_hidden_weak.
	* sysdeps/generic/math_private.h (libc_feholdsetround_ctx): Use
	__fegetenv instead of fegetenv.
	(libc_feholdsetround_noex_ctx): Likewise.
2014-12-31 22:07:52 +00:00
Chris Metcalf 1ff950ad20 Fix some warnings in the absence of FP round/exception support
Due to tile missing a bunch of FP exception and rounding
support, the tests generate warnings.  These changes fix the
warnings by just not compiling some unused functions, and
adding some attribute ((unused)) tags.
2014-12-30 14:11:13 -05:00