Commit Graph

611 Commits

Author SHA1 Message Date
Chris Metcalf 1dca195e1c lround: provide cast for wordsize-64 version if needed
Platforms with 64-bit registers where 32-bit values need to have the
high 32 bits set in a particular way need to have an explicit cast
when using the 64-bit sysdeps/ieee754/dbl-64/wordsize-64 version
of llround() as lround().  This includes tilegx32, and likely MIPS.
x32 does not need this, and AArch64 ILP32 will not either.  Require
it to be specified in sysdep.h to be explicit.
2015-01-05 11:59:32 -05: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 4a3d39994e Clean up powerpc fegetround / __fegetround inlines.
The natural fix for some linknamespace test failures, where C90 libm
functions call C99 <fenv.h> functions, is to make fe* into weak
aliases for __fe* and call __fe* from within libm as needed.

To do this, the __fe* names need to be available for that purpose -
that is, they must not be used for something other than aliases of
fe*.  On powerpc, however, __fegetround is an inline function in
fenv_libc.h, with no corresponding fegetround inline function;
fegetround has an equivalent macro expansion in bits/fenvinline.h, but
that is disabled if __NO_MATH_INLINES (which is defined for building
libm).

I see no need for that disabling; it's not even clear that
__NO_MATH_INLINES should affect <fenv.h>, and the results of
fegetround are completely defined so there is no semantic effect of
that disabling at all outside glibc.  The x86 inline feraiseexcept is
conditioned on __USE_EXTERN_INLINES not __NO_MATH_INLINES (but that's
an inline function rather than a macro).

This patch removes the __NO_MATH_INLINES conditional on that
fegetround macro, so resulting in it being expanded inline inside
glibc.  In turn, this means that direct calls to __fegetround from C99
functions in ldbl-128ibm can be changed to calls to fegetround, so
that nofpu fenv_libc.h files don't need to define __fegetround at all
and, by changing ldbl-128ibm files to use <fenv.h> not <fenv_libc.h>,
non-e500 nofpu no longer needs an fenv_libc.h file.

The other macros in fenvinline.h are left conditional on
__NO_MATH_INLINES, although since the only case where this should make
a difference is one involving undefined behavior (if the argument to
the function is not a valid exception macro).

The out-of-line definition for fegetround uses __fegetround (the
inline function removed by this patch).  So this continues to work,
the fenvinline.h header is made to define __fegetround, and then to
define fegetround to call __fegetround.

Tested for powerpc32 (hard float) that installed stripped shared
libraries are unchanged by this patch; also tested that powerpc-nofpu
build still works.  (This patch does not itself fix any bugs; it
simply cleans things up in preparation for separate bug fixes.)

	* sysdeps/powerpc/bits/fenvinline.h (fegetround): Rename macro to
	__fegetround and redefine to call __fegetround.  Remove condition
	on [!__NO_MATH_INLINES].
	* sysdeps/powerpc/fpu/fenv_libc.h (__fegetround): Remove inline
	function.
	* sysdeps/powerpc/nofpu/fenv_libc.h: Remove file.
	* sysdeps/powerpc/powerpc32/e500/nofpu/fenv_libc.h (__fegetround):
	Remove macro.
	* sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: Include <fenv.h>
	instead of <fenv_libc.h>.
	(__llrintl): Call fegetround instead of __fegetround.
	* sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: Include <fenv.h>
	instead of <fenv_libc.h>.
	* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: Likewise.
	(__lrintl): Call fegetround instead of __fegetround.
	* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: Include <fenv.h>
	instead of <fenv_libc.h>.
	* sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise.
	(__rintl): Call fegetround instead of __fegetround.
2014-12-31 19:16:34 +00:00
Joseph Myers f56f91245a Split __kernel_standard* functions (fixes bug 17724).
Bug 17724 reports references to fesetround being brought in by
ldbl-128ibm rintl via references to __rintl from __kernel_standard_l.
Because all three __kernel_standard* functions are in the same file,
this gets brought in even though only the long double version
__kernel_standard_l needs __rintl, and the C90 functions use only
__kernel_standard.

This patch fixes this by splitting the three versions into separate
files; it's fine for long double functions to refer to fe* functions
directly, unless they get called by C90 double functions.

Tested for x86_64 (testsuite; the reordering of code means disassembly
of shared libraries can't usefully be compared).  Tested for powerpc
that the relevant issue disappears from the linknamespace test
output.

	[BZ #17724]
	* sysdeps/ieee754/k_standard.c: Don't include <float.h>.
	(__kernel_standard_f): Remove.  Moved to k_standardf.c.
	(__kernel_standard_l): Remove.  Moved to k_standardl.c with
	(char *) casts added.
	* sysdeps/ieee754/k_standardf.c: New file.
	* sysdeps/ieee754/k_standardl.c: Likewise.
	* math/Makefile (libm-support): Remove k_standard.
	(libm-calls): Add k_standard.
2014-12-22 18:45:50 +00:00
Adhemerval Zanella 9d96909913 powerpc: Fix lgammal_r overflow warnings
ldbl-128ibm uses ldbl-128 e_lgammal_r implementation as is, however some
constants definitions overflows for IBM long double range.  This patch
suppress the compiler warnings until the ldbl-128ibm implementation is
fixed.
2014-12-11 07:17:11 -05:00
Joseph Myers 706688aaef FIx ldbl-128ibm frexpl for 32-bit systems (bug 16619, bug 16740).
This patch fixes bugs in ldbl-128ibm frexpl for 32-bit systems shown
up by warnings:

../sysdeps/ieee754/ldbl-128ibm/s_frexpl.c:82:4: warning: left shift count >= width of type
../sysdeps/ieee754/ldbl-128ibm/s_frexpl.c:129:5: warning: left shift count >= width of type

This did in fact show up in test-ldouble.out (alongside all the other
problems there ... maybe we should again consider running the libm
tests at finer granularity from the makefiles) as already covered by
the testsuite after the previous patch that fixed these bugs for
64-bit systems.  The fix is simply using 1LL instead of 1L when
shifting by 52.

Tested for powerpc32 (soft float).

	[BZ #16619]
	[BZ #16740]
	* sysdeps/ieee754/ldbl-128ibm/s_frexpl.c (__frexpl): Use 1LL << 52
	instead of 1L << 52.
2014-11-26 13:54:55 +00:00
Siddhesh Poyarekar a109996ef9 Remove IS_IN_libm
Replace with IS_IN (libm). Generated code unchanged on x86_64.

        * include/math.h: Use IS_IN instead of IS_IN_libm.
        * sysdeps/alpha/fpu/s_copysign.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_copysignl.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_finitel.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_fmal.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_frexpl.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_isinfl.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_isnanl.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_modfl.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c: Likewise.
        * sysdeps/ieee754/ldbl-128ibm/s_signbitl.c: Likewise.
        * sysdeps/ieee754/ldbl-64-128/s_copysignl.c: Likewise.
        * sysdeps/ieee754/ldbl-64-128/s_finitel.c: Likewise.
        * sysdeps/ieee754/ldbl-64-128/s_frexpl.c: Likewise.
        * sysdeps/ieee754/ldbl-64-128/s_isinfl.c: Likewise.
        * sysdeps/ieee754/ldbl-64-128/s_isnanl.c: Likewise.
        * sysdeps/ieee754/ldbl-64-128/s_modfl.c: Likewise.
        * sysdeps/ieee754/ldbl-64-128/s_scalbnl.c: Likewise.
        * sysdeps/ieee754/ldbl-64-128/s_signbitl.c: Likewise.
        * sysdeps/ieee754/ldbl-64-128/w_scalblnl.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_copysign.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_finite.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_frexp.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_isinf.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_isnan.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_ldexp.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_ldexpl.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_modf.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_scalbln.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/s_scalbn.c: Likewise.
        * sysdeps/powerpc/power5+/fpu/s_modf.c: Likewise.
        * sysdeps/powerpc/powerpc32/fpu/s_copysign.S: Likewise.
        * sysdeps/powerpc/powerpc32/fpu/s_copysignl.S: Likewise.
        * sysdeps/powerpc/powerpc32/fpu/s_isnan.S: Likewise.
        * sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c: Likewise.
        * sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c: Likewise.
        * sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c: Likewise.
        * sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c: Likewise.
        * sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modf.c: Likewise.
        * sysdeps/powerpc/powerpc32/power5/fpu/s_isnan.S: Likewise.
        * sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S: Likewise.
        * sysdeps/powerpc/powerpc32/power6/fpu/s_isnan.S: Likewise.
        * sysdeps/powerpc/powerpc32/power7/fpu/s_finite.S: Likewise.
        * sysdeps/powerpc/powerpc32/power7/fpu/s_isinf.S: Likewise.
        * sysdeps/powerpc/powerpc32/power7/fpu/s_isnan.S: Likewise.
        * sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c: Likewise.
        * sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c: Likewise.
        * sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c: Likewise.
        * sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c: Likewise.
        * sysdeps/powerpc/powerpc64/fpu/multiarch/s_modf.c: Likewise.
        * sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Likewise.
        * sysdeps/powerpc/powerpc64/fpu/s_copysignl.S: Likewise.
        * sysdeps/powerpc/powerpc64/fpu/s_isnan.S: Likewise.
        * sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S: Likewise.
        * sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S: Likewise.
        * sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S: Likewise.
        * sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S: Likewise.
        * sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S: Likewise.
        * sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S: Likewise.
        * sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S: Likewise.
        * sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S: Likewise.
        * sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S: Likewise.
        * sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S: Likewise.
        * sysdeps/sparc/sparc32/fpu/s_signbitl.S: Likewise.
        * sysdeps/sparc/sparc32/sparcv9/fpu/s_isnan.S: Likewise.
        * sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S: Likewise.
2014-11-24 11:41:47 +05:30
Joseph Myers 107a5bf085 Fix libm mpone, mptwo namespace (bug 17616).
libm uses symbols mpone and mptwo for internal purposes.  This patch
moves them to the implementation namespace (__mpone and __mptwo).

Tested for x86_64 (testsuite, and that installed stripped shared
libraries are unchanged by the patch).

	[BZ #17616]
	* sysdeps/ieee754/dbl-64/mpa.c (mpone): Rename to __mpone.
	(mptwo): Rename to __mptwo.
	(__inv): Use __mptwo instead of mptwo.
	* sysdeps/ieee754/dbl-64/mpa.h (mpone): Rename to __mpone.
	(mptwo): Rename to __mptwo.
	* sysdeps/ieee754/dbl-64/mpatan.c (__mpatan): Use __mpone instead
	of mpone and __mptwo instead of mptwo.
	* sysdeps/ieee754/dbl-64/mpatan2.c (__mpatan2): Use __mpone
	instead of mpone.
	* sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): Likewise.
	* sysdeps/ieee754/dbl-64/mplog.c (__mplog): Likewise.
	* sysdeps/ieee754/dbl-64/sincos32.c (__c32): Use __mpone instead
	of mpone and __mptwo instead of mptwo.
	(__mpranred): Use __mpone instead of mpone.
	* conform/Makefile (test-xfail-ISO/math.h/linknamespace): Remove
	variable.
	(test-xfail-ISO99/complex.h/linknamespace): Likewise.
	(test-xfail-ISO99/math.h/linknamespace): Likewise.
	(test-xfail-ISO99/tgmath.h/linknamespace): Likewise.
	(test-xfail-ISO11/complex.h/linknamespace): Likewise.
	(test-xfail-ISO11/math.h/linknamespace): Likewise.
	(test-xfail-ISO11/tgmath.h/linknamespace): Likewise.
	(test-xfail-XPG3/math.h/linknamespace): Likewise.
	(test-xfail-XPG4/math.h/linknamespace): Likewise.
	(test-xfail-POSIX/math.h/linknamespace): Likewise.
	(test-xfail-UNIX98/math.h/linknamespace): Likewise.
	(test-xfail-XOPEN2K/complex.h/linknamespace): Likewise.
	(test-xfail-XOPEN2K/math.h/linknamespace): Likewise.
	(test-xfail-XOPEN2K/tgmath.h/linknamespace): Likewise.
	(test-xfail-POSIX2008/complex.h/linknamespace): Likewise.
	(test-xfail-POSIX2008/math.h/linknamespace): Likewise.
	(test-xfail-POSIX2008/tgmath.h/linknamespace): Likewise.
	(test-xfail-XOPEN2K8/complex.h/linknamespace): Likewise.
	(test-xfail-XOPEN2K8/math.h/linknamespace): Likewise.
	(test-xfail-XOPEN2K8/tgmath.h/linknamespace): Likewise.
2014-11-18 15:40:56 +00:00
Andreas Schwab dacdc86717 Fix missing <math_private.h> in ldbl-96 fma 2014-08-04 10:20:20 +02:00
Richard Henderson 4896f04920 Force eval for fma implementations 2014-08-01 12:13:50 -10:00
Joseph Myers ce9c5b3e95 Fix ldbl-128 expm1l spurious underflow (bug 16539).
This patch fixes spurious underflows from ldbl-128 expm1l, as reported
in <https://sourceware.org/ml/libc-alpha/2014-06/msg00835.html> and
exposed by the tests added for such a bug in the x86 / x86-64
version.  The bug and fix are essentially the same, so no separate bug
is filed in Bugzilla.

Tested for mips64.

	[BZ #16539]
	* sysdeps/ieee754/ldbl-128/s_expm1l.c: Include <float.h>.
	(__expm1l): Return argument unchanged when small but not
	subnormal.
2014-06-30 17:38:16 +00:00
Joseph Myers edea402804 Fix ldbl-128 powl sign of result in overflow / underflow cases (bug 17097).
This patch fixes bug 17097, ldbl-128 powl producing overflowing /
underflowing results with positive sign when the result should have
been negative.  This was shown up by the tests in non-default rounding
modes added by my patch for bug 16315, but isn't actually limited to
non-default rounding modes: rather, when rounding to nearest the
wrappers produced a result with the correct sign and so always hid the
bug unless -lieee was used to disable the wrappers.  The problem is
that in the cases where Y is large enough that the result overflows or
underflows for X not very close to 1, but not large enough to overflow
or underflow for all X != +/- 1 (in the latter case Y is always an
even integer), a positive overflowing / underflowing result is always
returned, rather than one with the correct sign.  This patch moves the
relevant part of computation of the sign earlier and returns a result
of the correct sign.

Tested for mips64.

	[BZ #17097]
	* sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Return
	result with correct sign in case of exponents that produce
	overflow except for X very close to 1.
2014-06-29 11:49:08 +00:00
Joseph Myers be25493251 Fix yn overflow handling in non-default rounding modes (bug 16561, bug 16562).
This patch fixes bugs 16561 and 16562, bad results of yn in overflow
cases in non-default rounding modes, both because an intermediate
overflow in the recurrence does not get detected if the result is not
an infinity and because an overflowing result may occur in the wrong
sign.  The fix is to set FE_TONEAREST mode internally for the parts of
the function where such overflows can occur (which includes the call
to y1 - where yn is used to compute a Bessel function of order -1,
negating the result of y1 isn't correct for overflowing results in
directed rounding modes) and then compute an overflowing value in the
original rounding mode if the to-nearest result was an infinity.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 and powerpc32 to test the ldbl-128 and ldbl-128ibm changes.

(The tests for these bugs were added in my previous y1 patch, so the
only thing this patch has to do with the testsuite is enable yn
testing in all rounding modes.)

	[BZ #16561]
	[BZ #16562]
	* sysdeps/ieee754/dbl-64/e_jn.c: Include <float.h>.
	(__ieee754_yn): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/flt-32/e_jnf.c: Include <float.h>.
	(__ieee754_ynf): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/ldbl-128/e_jnl.c: Include <float.h>.
	(__ieee754_ynl): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Include <float.h>.
	(__ieee754_ynl): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/ldbl-96/e_jnl.c: Include <float.h>.
	(__ieee754_ynl): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/i386/fpu/fenv_private.h [!__SSE2_MATH__]
	(libc_feholdsetround_ctx): New macro.
	* math/libm-test.inc (yn_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps : Likewise.
2014-06-27 14:52:13 +00:00
Joseph Myers a638de828d Fix exp10 spurious underflows (bug 16560).
This patch fixes spurious underflows from exp10 for arguments near 0
(part of bug 16560; that bug also includes spurious underflows from
exp2, which are not fixed by this patch).  The problem is underflows
in the internal computation converting the exp10 argument to arguments
for exp (with extra precision), and the fix is simply to return 1
early for arguments near enough to 0 (just as arguments with large
enough magnitude have their own overflow / underflow logic at the
start of the function).

Tested x86_64 and x86 and ulps updated accordingly; also tested for
powerpc32 and mips64 to validate the ldbl-128ibm and ldbl-128 changes.

	[BZ #16560]
	* sysdeps/ieee754/dbl-64/e_exp10.c (__ieee754_exp10): Return 1 for
	arguments close to 0.
	* sysdeps/ieee754/ldbl-128/e_exp10l.c (__ieee754_exp10l):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_exp10l.c (__ieee754_exp10l):
	Likewise.
	* math/auto-libm-test-in: Add more tests of exp10.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2014-06-25 11:33:22 +00:00
Joseph Myers e7dd3c8c1d Fix ldbl-128 erfl spurious underflows (bug 16287).
This patch fixes bug 16287, spurious underflows from ldbl-128 erfl
arising from it calling erfcl for arguments with absolute value at
least 1.0, although for large positive arguments erfcl correctly
underflows but erfl shouldn't.  The fix is simply to avoid calling
erfcl, and just return 1, for arguments above a cut-off large enough
that erfl correctly rounds to-nearest as 1 but not so large that erfcl
underflows.

Tested mips64.  Also tested x86_64 and x86 to confirm the new tests
(taken from the tests of erfc) don't cause any problems there; no ulps
updates needed.

	[BZ #16287]
	* sysdeps/ieee754/ldbl-128/s_erfl.c (__erfl): Return 1 without
	calling __erfcl for arguments at least 16.
	* math/auto-libm-test-in: Add more tests of erf.
	* math/auto-libm-test-out: Regenerated.
2014-06-24 20:56:56 +00:00
Joseph Myers 4648909d56 Fix cosh spurious underflows from expm1 (bug 16354), inaccurate results near 0 (bug 17061).
This patch fixes bug 16354, spurious underflows from cosh when a tiny
argument is passed to expm1 and expm1 correctly underflows although
the final result of cosh should be 1.  As noted in that bug, some
cases are latent because of expm1 implementations not raising
underflow (bug 16353), but all the implementations are fixed
similarly.  They already contained checks for tiny arguments, but the
checks were too late to avoid underflow from expm1 (although they
would avoid underflow from subsequent squaring of the result of
expm1); they are moved before the expm1 calls.

The thresholds used for considering arguments tiny are not
particularly consistent in how they relate to the precision of the
floating-point format in question.  They are, however, all sufficient
to ensure that the round-to-nearest result of cosh is indeed 1 below
the threshold (although sometimes they are smaller than necessary).
But the previous logic did not return 1, but the previously computed 1
+ expm1(abs(x)) value.  And the thresholds in the ldbl-128 and
ldbl-128ibm code (0x1p-71L - I suspect 0x3f8b was intended in the code
instead of 0x3fb8 - and (roughly) 0x1p-55L) are not sufficient for
that value to be 1.  So by moving the test for tiny arguments, and
consequently returning 1 directly now the expm1 value hasn't been
computed by that point, this patch also fixes bug 17061, the (large
number of ulps) inaccuracy for small arguments in those
implementations.  Tests for that bug are duly added.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 and powerpc32 to validate the ldbl-128 and ldbl-128ibm changes.

	[BZ #16354]
	[BZ #17061]
	* sysdeps/ieee754/dbl-64/e_cosh.c (__ieee754_cosh): Check for
	small arguments before calling __expm1.
	* sysdeps/ieee754/flt-32/e_coshf.c (__ieee754_coshf): Check for
	small arguments before calling __expm1f.
	* sysdeps/ieee754/ldbl-128/e_coshl.c (__ieee754_coshl): Check for
	small arguments before calling __expm1l.
	* sysdeps/ieee754/ldbl-128ibm/e_coshl.c (__ieee754_coshl):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_coshl.c (__ieee754_coshl): Likewise.
	* math/auto-libm-test-in: Add more cosh tests.  Do not allow
	spurious underflow for some cosh tests.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2014-06-23 20:20:10 +00:00
Joseph Myers 46a3d3c7d6 Set errno for y1 overflow (bug 17050).
This patch fixes bug 17050, missing errno setting for y1 overflow (for
small positive arguments).  An appropriate check is added for overflow
directly in the __ieee754_y1 implementation, similar to the check
present for yn (doing it there rather than in the wrapper also avoids
yn needing to repeat the check when called for order 1 or -1 and it
uses __ieee754_y1).

Tested x86_64 and x86; no ulps update needed.  Also tested for mips64
to verify the ldbl-128 fix (the ldbl-128ibm code just #includes the
ldbl-128 file).

	[BZ #17050]
	* sysdeps/ieee754/dbl-64/e_j1.c: Include <errno.h>.
	(__ieee754_y1): Set errno if return value overflows.
	* sysdeps/ieee754/flt-32/e_j1f.c: Include <errno.h>.
	(__ieee754_y1f): Set errno if return value overflows.
	* sysdeps/ieee754/ldbl-128/e_j1l.c: Include <errno.h>.
	(__ieee754_y1l): Set errno if return value overflows.
	* sysdeps/ieee754/ldbl-96/e_j1l.c: Include <errno.h>.
	(__ieee754_y1l): Set errno if return value overflows.
	* math/auto-libm-test-in: Add more tests of y0, y1 and yn.
	* math/auto-libm-test-out: Regenerated.
2014-06-23 20:17:13 +00:00
Joseph Myers 4da6db5188 Fix pow overflow in non-default rounding modes (bug 16315).
This patch fixes bug 16315, bad pow handling of overflow/underflow in
non-default rounding modes.  Tests of pow are duly converted to
ALL_RM_TEST to run all tests in all rounding modes.

There are two main issues here.  First, various implementations
compute a negative result by negating a positive result, but this
yields inappropriate overflow / underflow values for directed
rounding, so either overflow / underflow results need recomputing in
the correct sign, or the relevant overflowing / underflowing operation
needs to be made to have a result of the correct sign.  Second, the
dbl-64 implementation sets FE_TONEAREST internally; in the overflow /
underflow case, the result needs recomputing in the original rounding
mode.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16315]
	* sysdeps/i386/fpu/e_pow.S (__ieee754_pow): Ensure possibly
	overflowing or underflowing operations take place with sign of
	result.
	* sysdeps/i386/fpu/e_powf.S (__ieee754_powf): Likewise.
	* sysdeps/i386/fpu/e_powl.S (__ieee754_powl): Likewise.
	* sysdeps/ieee754/dbl-64/e_pow.c: Include <math.h>.
	(__ieee754_pow): Recompute overflowing and underflowing results in
	original rounding mode.
	* sysdeps/x86/fpu/powl_helper.c: Include <stdbool.h>.
	(__powl_helper): Allow negative argument X and scale negated value
	as needed.  Avoid passing value outside [-1, 1] to f2xm1.
	* sysdeps/x86_64/fpu/e_powl.S (__ieee754_powl): Ensure possibly
	overflowing or underflowing operations take place with sign of
	result.
	* sysdeps/x86_64/fpu/multiarch/e_pow.c [HAVE_FMA4_SUPPORT]:
	Include <math.h>.
	* math/auto-libm-test-in: Add more tests of pow.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (pow_test): Use ALL_RM_TEST.
	(pow_tonearest_test_data): Remove.
	(pow_test_tonearest): Likewise.
	(pow_towardzero_test_data): Likewise.
	(pow_test_towardzero): Likewise.
	(pow_downward_test_data): Likewise.
	(pow_test_downward): Likewise.
	(pow_upward_test_data): Likewise.
	(pow_test_upward): Likewise.
	(main): Don't call removed functions.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-06-23 20:12:33 +00:00
Stefan Liebler 3ef6b85059 [BZ #6803] Set errno for scalbln, scalbn
Errno is not set and the testcases will fail.

Now the scalbln-aliases are removed in i386/m68
and the wrappers are used when calling the scalbln-functions.

On ia64 only scalblnf has its own implementation.
For scalbln and scalblnl the ieee754/dbl-64 and ieee754/ldbl-96 are used, thus
the wrappers are needed, too.
2014-06-20 07:48:20 +05:30
Rajalakshmi Srinivasaraghavan 754c5a08aa PowerPC: Fix nearbyintl failure for few inputs
This patch fixes few failures in nearbyintl() where the fraction part is
close to 0.5.i  The new tests added report few extra failures in
nearbyint_downward and nearbyint_towardzero which is a known issue.

Fixes #17031.
2014-06-17 08:46:25 -05:00
Joseph Myers f8ba1b5654 Fix log2 (1) in round-downward mode (bug 17042).
As with other issues of this kind, bug 17042 is log2 (1) wrongly
returning -0 instead of +0 in round-downward mode because of
implementations effectively in terms of log1p (x - 1).  This patch
fixes the issue in the same way used for log and log10.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 to confirm a fix was needed for ldbl-128 and to validate that
fix (also applied to ldbl-128ibm since that version of log2l is
essentially the same as the ldbl-128 one).

	[BZ #17042]
	* sysdeps/i386/fpu/e_log2.S (__ieee754_log2): Take absolete value
	when x - 1 is zero.
	* sysdeps/i386/fpu/e_log2f.S (__ieee754_log2f): Likewise.
	* sysdeps/i386/fpu/e_log2l.S (__ieee754_log2l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Return
	0.0L for an argument of 1.0L.
	* sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l):
	Likewise.
	* sysdeps/x86_64/fpu/e_log2l.S (__ieee754_log2l): Take absolute
	value when x - 1 is zero.
	* math/libm-test.inc (log2_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-06-10 12:07:15 +00:00
David S. Miller 30f3d07cbb Fix excessive ULP for y1_upward (0x2p+0) in test-float and test-ifloat.
* sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_y1f): Force computations
	to occur in round to nearest mode when |x| >= 2.0
2014-05-31 20:05:00 -07:00
Joseph Myers b72592e75f Fix log10 (1) in round-downward mode (bug 16977).
As with various other issues of this kind, bug 16977 is log10 (1)
wrongly returning -0 rather than +0 in round-downward mode because of
an implementation effectively in terms of log1p (x - 1).  This patch
fixes the issue in the same way used for log.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 to confirm a fix was needed for ldbl-128 and to validate that
fix (also applied to ldbl-128ibm since that version of logl is
essentially the same as the ldbl-128 one).

	[BZ #16977]
	* sysdeps/i386/fpu/e_log10.S (__ieee754_log10): Take absolute
	value when x - 1 is zero.
	* sysdeps/i386/fpu/e_log10f.S (__ieee754_log10f): Likewise.
	* sysdeps/i386/fpu/e_log10l.S (__ieee754_log10l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log10l.c (__ieee754_log10l): Return
	0.0L for an argument of 1.0L.
	* sysdeps/ieee754/ldbl-128ibm/e_log10l.c (__ieee754_log10l):
	Likewise.
	* sysdeps/x86_64/fpu/e_log10l.S (__ieee754_log10l): Take absolute
	value when x - 1 is zero.
	* math/libm-test.inc (log10_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-23 12:07:50 +00:00
Joseph Myers 1a84c3d6d4 Fix log1pl (LDBL_MAX) in FE_UPWARD mode (bug 16564).
Bug 16564 is spurious overflow of log1pl (LDBL_MAX) in FE_UPWARD mode,
resulting from log1pl adding 1 to its argument (for arguments not
close to 0), which overflows in that mode.  This patch fixes this by
avoiding adding 1 to large arguments (precisely what counts as large
depends on the floating-point format).

Tested x86_64 and x86, and spot-checked log1pl tests on mips64 and
powerpc64.

	[BZ #16564]
	* sysdeps/i386/fpu/s_log1pl.S (__log1pl): Do not add 1 to positive
	arguments with exponent 65 or above.
	* sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Do not add 1 to
	arguments 0x1p113L or above.
	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Do not add 1
	to arguments 0x1p107L or above.
	* sysdeps/x86_64/fpu/s_log1pl.S (__log1pl): Do not add 1 to
	positive arguments with exponent 65 or above.
	* math/auto-libm-test-in: Add more tests of log1p.
	* math/auto-libm-test-out: Regenerated.
2014-05-14 12:38:56 +00:00
Joseph Myers 913d03c864 Fix acosh (1) in round-downward mode (bug 16927).
According to C99 and C11 Annex F, acosh (1) should be +0 in all
rounding modes.  However, some implementations in glibc wrongly return
-0 in round-downward mode (which is what you get if you end up
computing log1p (-0), via 1 - 1 being -0 in round-downward mode).
This patch fixes the problem implementations, by correcting the test
for an exact 1 value in the ldbl-96 implementation to allow for the
explicit high bit of the mantissa, and by inserting fabs instructions
in the i386 implementations; tests of acosh are duly converted to
ALL_RM_TEST.  I believe all the other sysdeps/ieee754 implementations
are already OK (I haven't checked the ia64 versions, but if buggy then
that will be obvious from the results of test runs after this patch is
in).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16927]
	* sysdeps/i386/fpu/e_acosh.S (__ieee754_acosh): Use fabs on x-1
	value.
	* sysdeps/i386/fpu/e_acoshf.S (__ieee754_acoshf): Likewise.
	* sysdeps/i386/fpu/e_acoshl.S (__ieee754_acoshl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_acoshl.c (__ieee754_acoshl): Correct
	for explicit high bit of mantissa when testing for argument equal
	to 1.
	* math/libm-test.inc (acosh_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-14 12:35:40 +00:00
Joseph Myers 0bf061d3e3 Fix erf underflow handling near 0 (bug 16516).
Bug 16516 reports spurious underflows from erf (for all floating-point
types), when the result is close to underflowing but does not actually
underflow.

erf (x) is about (2/sqrt(pi))*x for x close to 0, so there are
subnormal arguments for which it does not underflow.  The various
implementations do (x + efx*x) (for efx = 2/sqrt(pi) - 1), for greater
accuracy than if just using a single multiplication by an
approximation to 2/sqrt(pi) (effectively, this way there are a few
more bits in the approximation to 2/sqrt(pi)).  This can introduce
underflows when efx*x underflows even though the final result does
not, so a scaled calculation with 8*efx is done in these cases - but 8
is not a big enough scale factor to avoid all such underflows.  16 is
(any underflows with a scale factor of 16 would only occur when the
final result underflows), so this patch changes the code to use that
factor.  Rather than recomputing all the values of the efx8 variable,
it is removed, leaving it to the compiler's constant folding to
compute 16*efx.  As such scaling can also lose underflows when the
final scaling down happens to be exact, appropriate checks are added
to ensure underflow exceptions occur when required in such cases.

Tested x86_64 and x86; no ulps updates needed.  Also spot-checked for
powerpc32 and mips64 to verify the changes to the ldbl-128ibm and
ldbl-128 implementations.

	[BZ #16516]
	* sysdeps/ieee754/dbl-64/s_erf.c (efx8): Remove variable.
	(__erf): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/flt-32/s_erff.c (efx8): Remove variable.
	(__erff): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-128/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-96/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* math/auto-libm-test-in: Add more tests of erf.
	* math/auto-libm-test-out: Regenerated.
2014-05-14 12:34:03 +00:00
Stefan Liebler 2ca180e97a [BZ #16823] Fix log1pl returning wrong infinity sign 2014-04-29 15:43:36 +02:00
Stefan Liebler 8ea587db2b [BZ #16824] Fix failing y1 due to too large ulps in downward/upward rounding mode. 2014-04-16 13:03:46 +02:00
Alan Modra aa5f0ff11a Correct IBM long double frexpl.
Besides fixing the bugzilla, this also fixes corner-cases where the high
and low double differ greatly in magnitude, and handles a denormal
input without resorting to a fp rescale.

	[BZ #16740]
	[BZ #16619]
	* sysdeps/ieee754/ldbl-128ibm/s_frexpl.c (__frexpl): Rewrite.
	* math/libm-test.inc (frexp_test_data): Add tests.
2014-04-16 19:33:32 +09:30
Joseph Myers a84e78c8b3 Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800).
This patch fixes incorrect results from catan and catanh of certain
special inputs in round-downward mode (bug 16799), and incorrect
results of __ieee754_logf (+/-0) in round-downward mode (bug 16800)
that show up through catan/catanh when tested in all rounding modes,
but not directly in the testing for logf because the bug gets hidden
by the wrappers.

Both bugs involve a zero that should be +0 being -0 instead: one
computed as (1-x)*(1+x) in the catan/catanh case, and one as (x-x) in
the logf case.  The fixes ensure positive zero is used.  Testing of
catan and catanh in all rounding modes is duly enabled.

I expect there are various other bugs in special cases in __ieee754_*
functions that are normally hidden by the wrappers but would show up
for testing with -lieee (or in future with -fno-math-errno if we
replace -lieee and _LIB_VERSION with compile-time redirection to new
*_noerrno symbol names).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16799]
	[BZ #16800]
	* math/s_catan.c (__catan): Avoid passing -0 denominator to atan2
	with 0 numerator.
	* math/s_catanf.c (__catanf): Likewise.
	* math/s_catanh.c (__catanh): Likewise.
	* math/s_catanhf.c (__catanhf): Likewise.
	* math/s_catanhl.c (__catanhl): Likewise.
	* math/s_catanl.c (__catanl): Likewise.
	* sysdeps/ieee754/flt-32/e_logf.c (__ieee754_logf): Always divide
	by positive zero when computing -Inf result.
	* math/libm-test.inc (catan_test): Use ALL_RM_TEST.
	(catanh_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-04-02 17:41:02 +00:00
Alan Modra b0abbc2103 Correct IBM long double nextafterl.
Fix for values near a power of two, and some tidies.

	[BZ #16739]
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl): Correct
	output when value is near a power of two.  Use int64_t for lx and
	remove casts.  Use decimal rather than hex exponent constants.
	Don't use long double multiplication when double will suffice.
	* math/libm-test.inc (nextafter_test_data): Add tests.
	* NEWS: Add 16739 and 16786 to bug list.
2014-04-02 13:46:19 +10:30
Joseph Myers f3426898bf Fix implicit __isinf declarations in exp.
My recent exp patch introduced warnings about implicit __isinf
declarations in exp because e_exp.c didn't include <math.h>.  This
patch fixes this.  Because <math.h> can't be included after
<math_private.h> (because of macro definitions of __nan*), it was
necessary to put an include in sysdeps/x86_64/fpu/multiarch/e_exp.c as
well.

Tested x86_64.

	* sysdeps/ieee754/dbl-64/e_exp.c: Include <math.h>.
	* sysdeps/x86_64/fpu/multiarch/e_exp.c
	[HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise.
2014-03-24 22:00:32 +00:00
Joseph Myers b376a11a19 Fix dbl-64 exp overflow/underflow in non-default rounding modes (bug 16284).
The dbl-64 version of exp needs round-to-nearest mode for its internal
computations, but that has the consequence of inappropriate
overflowing and underflowing results in other rounding modes.  This
patch fixes this by recomputing the relevant results in cases where
the round-to-nearest result overflows to infinity or underflows to
zero (most of the diffs are actually just consequent reindentation).
Tests are enabled in all rounding modes for complex functions using
exp - but not for cexp because it turns out there are bugs causing
spurious underflows for cexp for some tests, which will need to be
fixed separately (I suspect ccos ccosh csin csinh ctan ctanh have
similar bugs, just not shown by the present set of test inputs).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16284]
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Use original
	rounding mode to recompute results that overflow to infinity or
	underflow to zero.
	* math/auto-libm-test-in: Don't mark tests as expected to fail for
	bug 16284.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (ccos_test): Use ALL_RM_TEST.
	(ccosh_test): Likewise.
	(csin_test_data): Use plus_oflow.
	(csin_test): Use ALL_RM_TEST.
	(csinh_test_data): Use plus_oflow.
	(csinh_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-24 12:18:45 +00:00
Joseph Myers f7be737659 Fix log (1) in round-downward mode (bug 16731).
According to ISO C Annex F, log (1) should be +0 in all rounding
modes, but some implementations in glibc wrongly return -0 in
round-downward mode (mapping to log1p (x - 1) is problematic because 1
- 1 is -0 in round-downward mode, and log1p (-0) is -0).  This patch
fixes this.  (It helps with some implementations of other functions
such as acosh, log2 and log10 that call out to log, but not enough to
enable all-rounding-modes testing for those functions without further
fixes to other implementations of them.)

Tested x86_64 and x86 and ulps updated accordingly, and did spot tests
for mips64 for the ldbl-128 fix, and i586 for the sysdeps/i386/fpu
implementations shadowed by those in sysdeps/i386/i686/fpu.

	[BZ #16731]
	* sysdeps/i386/fpu/e_log.S (__ieee754_log): Take absolute value
	when x - 1 is zero.
	* sysdeps/i386/fpu/e_logf.S (__ieee754_logf): Likewise.
	* sysdeps/i386/fpu/e_logl.S (__ieee754_logl): Likewise.
	* sysdeps/i386/i686/fpu/e_logl.S (__ieee754_logl): Likewise.
	* sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Return +0 when
	argument is 1.
	* sysdeps/ieee754/ldbl-128/e_logl.c (__ieee754_logl): Likewise.
	* sysdeps/x86_64/fpu/e_logl.S: Take absolute value when x - 1 is
	zero.
	* math/libm-test.inc (log_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-21 18:13:58 +00:00
Joseph Myers 600fa36158 Fix nextafter overflow in non-default rounding modes (bug 16677).
ISO C requires the result of nextafter to be independent of the
rounding mode, even when underflow or overflow occurs.  This patch
fixes the bug in various nextafter implementations that, having done
an overflowing computation to force an overflow exception (correct),
they then return the result of that computation rather than an
infinity computed some other way (incorrect, when the overflowing
result of arithmetic with that sign and rounding mode is finite but
the correct result is infinite) - generally by falling through to
existing code to return a value that in fact is correct for this case
(but was computed by an integer increment and so without generating
the exceptions required).  Having fixed the bug, the previously
deferred conversion of nextafter testing in libm-test.inc to
ALL_RM_TEST is also included.

Tested x86_64 and x86; also spot-checked results of nextafter tests
for powerpc32 and mips64 to test the ldbl-128ibm and ldbl-128
changes.  (The m68k change is untested.)

	[BZ #16677]
	* math/s_nextafter.c (__nextafter): Do not return value from
	overflowing computation.
	* sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* sysdeps/ieee754/flt-32/s_nextafterf.c (__nextafterf): Likewise.
	* sysdeps/ieee754/ldbl-128/s_nextafterl.c (__nextafterl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* math/libm-test.inc (nextafter_test): Use ALL_RM_TEST.
2014-03-11 22:24:00 +00:00
Siddhesh Poyarekar 1cadc85813 Fix sign of input to bsloww1 (BZ #16623)
In 84ba214c, I removed some redundant sign computations and in the
process, I incorrectly got rid of a temporary variable, thus passing
the absolute value of the input to bsloww1.  This caused #16623.

This fix undoes the incorrect change.
2014-02-27 21:12:09 +05:30
Andreas Krebbel 7e6424e343 BZ #16447: Fix ldbl-128 expl implementation.
Extend the range of numbers handled via unsafe mode.
Add expl testcase and regenerate ULPs for s390.
2014-02-11 13:47:47 +01:00
Ondřej Bílka a1ffb40e32 Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
Andreas Krebbel 7beb48cbb7 [BZ #16427] Fix ldbl-128 exp overflows.
Invoke the non-IEEE handling only for numbers special also in the IEEE
case.  This aligns the exp handling with the other ldbl variants.
2014-01-15 09:50:31 +01:00
Adhemerval Zanella 38f3458175 PowerPC: remove wrong truncl implementation for PowerPC64
The truncl assembly implementation (sysdeps/powerpc/powerpc64/fpu/s_truncl.S)
returns wrong results for some inputs where first double is a exact integer
and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_truncl.c instead it fixes tgammal
issues regarding wrong result sign.
2014-01-08 08:14:48 -06:00
Joseph Myers 4c327f2ad8 Fix ldbl-128ibm expm1l on large arguments (bug 16408).
This patch fixes bug 16408, ldbl-128ibm expm1l returning NaN for some
large arguments.

The basic problem is that the approach of converting the exponent to
the form n * log(2) + y, where -0.5 <= y <= 0.5, then computing 2^n *
expm1(y) + (2^n - 1) falls over when 2^n overflows (starting slightly
before the point where expm1 overflows, when y is negative and n is
the least integer for which 2^n overflows).  The ldbl-128 code, and
the x86/x86_64 code, make expm1l fall back to expl for large positive
arguments to avoid this issue.  This patch makes the ldbl-128ibm code
do the same.  (The problem appears for the particular argument in the
testsuite because the ldbl-128ibm code also uses an overflow threshold
that's for ldbl-128 and is too big for ldbl-128ibm, but the problem
described applies for large non-overflowing cases as well, although
during the freeze is not a suitable time for making the expm1 tests
cover cases close to overflow more thoroughly.)

This leaves some code for large positive arguments in expm1l that is
now dead.  To keep the code for ldbl-128 and ldbl-128ibm similar, and
to avoid unnecessary changes during the freeze, the patch doesn't
remove it; instead I propose to file a bug in Bugzilla as a reminder
that this code (for overflow, including errno setting, and for
arguments of +Inf) is no longer needed and should be removed from both
those expm1l implementations.

Tested powerpc32.

	* sysdeps/ieee754/ldbl-128ibm/s_expm1l.c (__expm1l): Use __expl
	for large positive arguments.
2014-01-08 13:32:39 +00:00
Joseph Myers b821f414e4 Fix ldbl-128ibm coshl spurious overflows (bug 16407).
This patch fixes bug 16407, spurious overflows from ldbl-128ibm coshl.
The implementation assumed that a high part (reinterpreted as an
integer) of the absolute value of the argument of 0x408633ce8fb9f87dLL
or more meant overflow, but the actual threshold has high part
0x408633ce8fb9f87eLL (and a negative low part).  The patch adjusts the
threshold accordingly.

sinhl probably has the same issue, but I didn't get that far in adding
tests of special cases (such as just below and above overflow) before
the freeze and during the freeze is not a suitable time to add them
(as they'd require ulps to be regenerated again), so I'm not changing
that function for now; when I add more tests of special cases, we'll
discover whether sinhl indeed has this problem.

Tested powerpc32.

	* sysdeps/ieee754/ldbl-128ibm/e_coshl.c (__ieee754_coshl):
	Increase overflow threshold.
2014-01-07 22:00:04 +00:00
Joseph Myers eb3fc44b56 Fix ldbl-128 / ldbl-128ibm lgammal spurious underflow (bug 16400).
This patch fixes bug 16400, spurious underflow exceptions for ldbl-128
/ ldbl-128ibm lgammal with small positive arguments, by just using
-__logl (x) as the result in the problem cases (similar to the
previous fix for problems with small negative arguments).

Tested powerpc32, and also tested on mips64 that this does not require
ulps regeneration for the ldbl-128 case.

	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r):
	Return -__logl (x) for small positive arguments without evaluating
	a polynomial.
2014-01-06 18:20:20 +00:00
Joseph Myers 819e5d50dd Fix ldbl-128ibm logl inaccuracy (bug 16386).
This patch fixes bug 16386, ldbl-128ibm logl inaccuracy (with
consequent inaccuracy for lgammal) for arguments where the high double
is subnormal, which showed up while attempting to regenerate ulps for
powerpc-nofpu for 2.19.  The problem here is logic failing to allow
for subnormals when calculating the exponent of the argument.  Tested
for powerpc-nofpu.

	* sysdeps/ieee754/ldbl-128ibm/e_logl.c (__ieee754_logl): Adjust
	numbers with subnormal high part when calculating exponent.
2014-01-02 16:35:46 +00:00
Joseph Myers 90b6a1e55f Fix ldbl-128ibm asinhl inaccuracy (bug 16385).
This patch fixes bug 16385, ldbl-128ibm asinhl inaccuracy, which
showed up while attempting to regenerate ulps for powerpc-nofpu for
2.19.  The problem here was use of fabs instead of fabsl meaning large
arguments were reduced to the precision of double.  Tested for
powerpc-nofpu.

	* sysdeps/ieee754/ldbl-128ibm/s_asinhl.c (__asinhl): Use fabsl not
	fabs.
2014-01-02 16:34:24 +00:00
Joseph Myers 396e3ecf3e Fix ldbl-128ibm acoshl inaccuracy (bug 16384).
This patch fixes bug 16384, ldbl-128ibm acoshl inaccuracy, which
showed up while attempting to regenerate ulps for powerpc-nofpu for
2.19.  There were two separate problems, use of __log1p instead of
__log1pl and an insufficiently accurate constant value for log 2
(which this patch replaces by use of M_LN2l), each of which could
cause substantial inaccuracy in affected cases.

Tested for powerpc-nofpu.

	* sysdeps/ieee754/ldbl-128ibm/e_acoshl.c (ln2): Initialize with
	M_LN2l.
	(__ieee754_acoshl): Use __log1pl not __log1p.
2014-01-02 16:33:06 +00:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Allan McRae 6c9642eda6 Fix typo in csloww()
An incorrect variable name was used during the refactoring done in
commit 4aafb73c.
2013-12-27 12:29:38 +10:00
Joseph Myers 4f40e4b307 Fix ldbl-128 lgammal for small negative arguments (bug 16337).
This patch fixes bug 16337, ldbl-128 lgammal spurious overflows for
small negative arguments (the arguments in question are already in the
testsuite).  The implementation uses the reflection formula to compute
lgamma of negative x from lgamma of -x, effectively resulting in a
calculation -log(x^2) + log(-x); cancellation isn't problematic in
this case (bugs for problematic cancellation in lgamma are 2542, 2543,
2558), but the x^2 calculation can underflow (in which case there is
spurious logic to return an overflowing value - lgamma can only ever
correctly overflow for large positive arguments, though tgamma can
overflow for small arguments of either sign as well as large positive
arguments).  The fix is simply to calculate the result directly with
logl when the argument is a small enough negative number.

Tested mips64.

	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r):
	Calculate results for small negative arguments directly rather
	than using reflection formula with special underflow handling.
2013-12-22 20:50:16 +00:00