Commit Graph

67 Commits

Author SHA1 Message Date
Joseph Myers 7e1e68b45c Rework gen-libm-test.pl input/output handling.
This patch reworks how input and output files are specified for
gen-libm-test.pl.

Previously, the script had names of various inputs and outputs
hardcoded, with a -o option to specify an output directory.  This
patch replaces this with all inputs and outputs being specified
explicitly as the arguments of options passed to the script.  Outputs
are only generated if the relevant option is passed, and only the
processing required for the indicated outputs is done.  The Makefile
is made to pass options for generating libm-test-ulps.h in a separate
invocation of gen-libm-test.pl from that generating libm-test.c.

This is all in preparation for splitting up libm-test.inc and
auto-libm-test-out and running tests separately for each function,
when gen-libm-test.pl will be run separately for each function to
generate the .c file but only once to generate libm-test-ulps.h (and
those runs will be able to be in parallel).

Tested for x86_64.  The generated libm-test.c and libm-test-ulps.h are
identical before and after the patch.  Also tested the "make
regen-ulps" case.

	* math/gen-libm-test.pl ($output_dir): Remove variable.
	($srcdir): Likewise.
	($opt_a): New variable.
	($opt_c): Likewise.
	($opt_C): Likewise.
	($opt_H): Likewise.
	(-n): Make option take argument and use it as NewUlps output.
	(-a): New option.  Use its argument for auto-libm-test-out input.
	(-c): New option.  Use its argument for libm-test.inc input.
	(-C): New option.  Use its argument for libm-test.c output.
	(-H): New option.  Use its argument for libm-test-ulps.h output.
	(top level): Only process inputs needed to generate outputs
	specified by command-line options.  Only generate outputs
	specified by command-line options.
	* math/README.libm-test: Update example gen-libm-test.pl command.
	* math/Makefile ($(objpfx)libm-test.stmp): Update gen-libm-test.pl
	commands.
	(regen-ulps): Likewise.
2017-02-06 18:21:06 +00:00
Joseph Myers fbb31e20bc XFAIL libm-test.inc tests as needed for ibm128.
This patch arranges for various libm-test.inc tests to be XFAILed for
ibm128-libgcc in non-default rounding modes.  The tests are marked
with XFAIL_ROUNDING_IBM128_LIBGCC and gen-libm-test.pl is made to
transform that to XFAIL_IBM128_LIBGCC or 0 depending on the rounding
mode.

This should allow test-ldouble, test-ildouble and test-ldouble-finite
to pass with unmodified libgcc, given an ulps regeneration.  (The case
of patched libgcc was already clean up to ulps and possibly hypot
cases very close to the overflow threshold that may need more
XFAILing; patched libgcc, which should work with
TEST_COND_ibm128_libgcc defined to 0 to disable all these XFAILs, does
need slightly different ulps from unpatched.)  Note that soft-float
powerpc will still fail because of
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64811> resulting in
spurious "invalid" exceptions in the libgcc code (for hard float,
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58684> hides that bug).

Tested for powerpc.

	* math/libm-test.inc (XFAIL_IBM128_LIBGCC): New macro.
	(fdim_test_data): Use XFAIL_ROUNDING_IBM128_LIBGCC for some tests.
	(fma_test_data): Likewise.
	(hypot_test_data): Likewise.
	(log1p_test_data): Likewise.
	(modf_test_data): Likewise.
	(pow_test_data): Likewise.
	(remainder_test_data): Likewise.
	(remquo_test_data): Likewise.
	(scalb_test_data): Likewise.
	(scalbn_test_data): Likewise.
	(scalbln_test_data): Likewise.
	* math/gen-libm-test.pl (parse_args): Transform
	XFAIL_ROUNDING_IBM128_LIBGCC to XFAIL_IBM128_LIBGCC or 0 depending
	on the rounding mode.
2017-01-10 00:14:09 +00:00
Joseph Myers bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Joseph Myers 423c2b9d08 Add fromfp functions.
TS 18661-1 defines fromfp functions (fromfp, fromfpx, ufromfp,
ufromfpx, and float and long double variants) to convert from
floating-point to an integer type with any signedness and any given
width up to that of intmax_t, in any of the five IEEE rounding modes
(the usual four for binary floating point, plus rounding to nearest
with ties rounding away from zero), with control of whether in-range
non-integer values should result in the "inexact" exception being
raised.  This patch implements these functions for glibc.

These implementations are (apart from raising exceptions) pure integer
implementations; it's entirely possible optimized versions could be
devised for some architectures.  A common math/fromfp.h header
provides various common helper code that can readily be shared between
the implementations for different types.  For each type, the bulk of
the implementation is also shared between the four functions, with
wrappers that define UNSIGNED and INEXACT macros appropriately before
including the main implementation.

As the functions return intmax_t and uintmax_t without math.h being
allowed to expose those typedef names, they are declared using
__intmax_t and __uintmax_t as obtained from <bits/types.h>.

The FP_INT_* rounding direction macros are defined as ascending
integers in the order the names are listed in the TS; I see no
significant value in allowing architectures to vary the values of
them.

The libm-test machinery is duly adapted to handle unsigned int
arguments, and intmax_t and uintmax_t results.  Because each test
input is generally tested for four functions, five rounding modes and
several different widths, the libm-test.inc additions are very large.
Thus, the diffs in the body of this message exclude the libm-test.inc
changes, with the full patch being attached gzipped.  The bulk of the
new tests were generated (expanded from a test input plus rounding
results and information about where it lies in the relevant interval
between integers, to libm-test tests for all relevant combinations of
function, rounding direction and width) by a script that's included in
the patch as math/gen-fromfp-tests.py (input data
math/gen-fromfp-tests-inputs); as an ad hoc script that's not really
expected to be rerun, it's not very polished, but it's at least
plausibly useful for adding any further tests for these functions in
future.  I may split the libm-test tests up by function in future (so
both libm-test.inc and auto-libm-test-out are split into separate
files, and the tests for each function are also built and run
separately), but not for 2.25.

For no obvious reason, adding tgmath tests for the new functions
resulted in -Wuninitialized errors from test-tgmath.c about the
variable i being used uninitialized.  Those errors were correct - the
variable is read by the frexp version in test-tgmath.c (where real
frexp would write through that pointer instead of reading it) - but I
don't know why this patch would result in the pre-existing issue being
newly detected.  The patch initializes the variable to avoid those
errors.

With these changes, glibc 2.25 should have all the library features
from TS 18661-1 other than the functions that round result to narrower
type (and constant rounding directions, but I'm considering those
mainly a compiler feature not a library one).

Tested for x86_64, x86, mips64 and powerpc.

	* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(fromfp): New declaration.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise.
	* math/tgmath.h (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): New macro.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfp): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise.
	* math/math.h: Include <bits/types.h>.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_INT_UPWARD): New enum
	constant and macro.
	(FP_INT_DOWNWARD): Likewise.
	(FP_INT_TOWARDZERO): Likewise.
	(FP_INT_TONEARESTFROMZERO): Likewise.
	(FP_INT_TONEAREST): Likewise.
	* math/Versions (fromfp): New libm symbol at version GLIBC_2.25.
	(fromfpf): Likewise.
	(fromfpl): Likewise.
	(ufromfp): Likewise.
	(ufromfpf): Likewise.
	(ufromfpl): Likewise.
	(fromfpx): Likewise.
	(fromfpxf): Likewise.
	(fromfpxl): Likewise.
	(ufromfpx): Likewise.
	(ufromfpxf): Likewise.
	(ufromfpxl): Likewise.
	* math/Makefile (libm-calls): Add s_fromfpF, s_ufromfpF,
	s_fromfpxF and s_ufromfpxF.
	* math/gen-fromfp-tests.py: New file.
	* math/gen-fromfp-tests-inputs: Likewise.
	* math/libm-test.inc: Include <stdint.h>
	(check_intmax_t): New function.
	(check_uintmax_t): Likewise.
	(struct test_fiu_M_data): New type.
	(struct test_fiu_U_data): Likewise.
	(RUN_TEST_fiu_M): New macro.
	(RUN_TEST_LOOP_fiu_M): Likewise.
	(RUN_TEST_fiu_U): Likewise.
	(RUN_TEST_LOOP_fiu_U): Likewise.
	(fromfp_test_data): New array.
	(fromfp_test): New function.
	(fromfpx_test_data): New array.
	(fromfpx_test): New function.
	(ufromfp_test_data): New array.
	(ufromfp_test): New function.
	(ufromfpx_test_data): New array.
	(ufromfpx_test): New function.
	(main): Call fromfp_test, fromfpx_test, ufromfp_test and
	ufromfpx_test.
	* math/gen-libm-test.pl (parse_args): Handle u, M and U descriptor
	characters.
	* math/test-tgmath-ret.c: Include <stdint.h>.
	(rm): New variable.
	(width): Likewise.
	(CHECK_RET_CONST_TYPE): Take extra arguments and pass them to
	called function.
	(CHECK_RET_CONST_FLOAT): Take extra arguments and pass them to
	CHECK_RET_CONST_TYPE.
	(CHECK_RET_CONST_DOUBLE): Likewise.
	(CHECK_RET_CONST_LDOUBLE): Likewise.
	(CHECK_RET_CONST): Take extra arguments and pass them to calls
	macros.
	(fromfp): New CHECK_RET_CONST call.
	(ufromfp): Likewise.
	(fromfpx): Likewise.
	(ufromfpx): Likewise.
	(do_test): Call check_return_fromfp, check_return_ufromfp,
	check_return_fromfpx and check_return_ufromfpx.
	* math/test-tgmath.c: Include <stdint.h>
	(NCALLS): Increase to 138.
	(F(compile_test)): Initialize i.  Call fromfp functions.
	(F(fromfp)): New function.
	(F(fromfpx)): Likewise.
	(F(ufromfp)): Likewise.
	(F(ufromfpx)): Likewise.
	* manual/arith.texi (Rounding Functions): Document FP_INT_UPWARD,
	FP_INT_DOWNWARD, FP_INT_TOWARDZERO, FP_INT_TONEARESTFROMZERO,
	FP_INT_TONEAREST, fromfp, fromfpf, fromfpl, ufromfp, ufromfpf,
	ufromfpl, fromfpx, fromfpxf, fromfpxl, ufromfpx, ufromfpxf and
	ufromfpxl.
	* manual/libm-err-tab.pl (@all_functions): Add fromfp, fromfpx,
	ufromfp and ufromfpx.
	* math/fromfp.h: New file.
	* sysdeps/ieee754/dbl-64/s_fromfp.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fromfp_main.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fromfpx.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_ufromfp.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_ufromfpx.c: Likewise.
	* sysdeps/ieee754/flt-32/s_fromfpf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_fromfpf_main.c: Likewise.
	* sysdeps/ieee754/flt-32/s_fromfpxf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_ufromfpf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_ufromfpxf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_fromfpl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_fromfpl_main.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_fromfpxl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_ufromfpl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_ufromfpxl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_fromfpl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_fromfpl_main.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_fromfpxl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_ufromfpl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_ufromfpxl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fromfpl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fromfpl_main.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fromfpxl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_ufromfpl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_ufromfpxl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fromfp,
	ufromfp, fromfpx and ufromfpx.
	(CFLAGS-nldbl-fromfp.c): New variable.
	(CFLAGS-nldbl-fromfpx.c): Likewise.
	(CFLAGS-nldbl-ufromfp.c): Likewise.
	(CFLAGS-nldbl-ufromfpx.c): Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include <stdint.h>.
	* sysdeps/ieee754/ldbl-opt/nldbl-fromfp.c: New file.
	* sysdeps/ieee754/ldbl-opt/nldbl-fromfpx.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-ufromfp.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-ufromfpx.c: Likewise.
	* sysdeps/nacl/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2016-12-31 00:40:59 +00:00
Joseph Myers f8e8b8ed9f Add getpayload, getpayloadf, getpayloadl.
TS 18661-1 defines functions for manipulating the payloads of NaNs.
This patch implements the getpayload functions for glibc; these
extract the NaN payload (from an argument passed as a pointer, for
which corresponding libm-test support is added) and return it in the
same floating-point type.  The return value of these functions is
unspecified for non-NaN arguments; the patch does the simplest thing
to implement, which is that the functions do not check whether the
argument is a NaN and just treat the relevant bits of the
representation as a payload regardless.  A conversion from integer to
floating-point is used to produce the required return value, except in
the ldbl-128 case; as 128-bit integers are not supported for all
configurations using ldbl-128, the code constructs the required
floating-point representation of the return value directly instead.

Tested for x86_64, x86, mips64 and powerpc.

	* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(getpayload): New declaration.
	* math/Versions (getpayload): New libm symbol at version
	GLIBC_2.25.
	(getpayloadf): Likewise.
	(getpayloadl): Likewise.
	* math/Makefile (libm-calls): Add s_getpayloadF.
	* math/libm-test.inc: Include <nan-high-order-bit.h>.
	(struct test_f_f_data): Add comment.
	(RUN_TEST_fp_f): New macro.
	(RUN_TEST_LOOP_fp_f): Likewise.
	(getpayload_test_data): New array.
	(getpayload_test): New function.
	(main): Call getpayload_test.
	* math/gen-libm-test.pl (parse_args): Handle 'p' in argument
	descriptor.
	* manual/arith.texi (FP Bit Twiddling): Document getpayload,
	getpayloadf and getpayloadl.
	* manual/libm-err-tab.pl: Update comment on interfaces without
	ulps tabulated.
	* sysdeps/ieee754/dbl-64/s_getpayload.c: New file.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c: Likewise.
	* sysdeps/ieee754/flt-32/s_getpayloadf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_getpayloadl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_getpayloadl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_getpayloadl.c: Likewise.
	* sysdeps/nacl/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2016-10-19 01:49:09 +00:00
Joseph Myers 5e9d98a3d9 Add totalorder, totalorderf, totalorderl.
TS 18661-1 defines totalorder functions implementing the totalOrder
comparison operation from IEEE 754-2008.  This patch implements these
functions for glibc, including the type-generic macro in <tgmath.h>.
(The totalordermag functions will be added in a separate patch.)

The description of the totalOrder operation is complicated.  However,
for IEEE interchange binary formats and the preferred quiet NaN
convention, what that complicated description means is that you
interpret the representation as a sign-magnitude integer (with -0
coming before +0) and do a <= comparison on that interpretation.  For
finite values and infinities the ordering of the sign-magnitude
integers is just the same as the ordering of floating-point values, so
this extends that to all representations.  (Different representations
of the same floating-point value - which includes same quantum in the
decimal case - must still be considered equal by this operation, but
that issue doesn't arise for IEEE interchange binary formats.)  So the
complications are:

* When MIPS quiet NaN conventions are in use, the representation of
  NaNs needs adjusting before making such an integer comparison.  This
  patch does this adjustment only when both arguments are NaNs, as
  there's no need for it if only one is a NaN, and as long as both are
  NaNs you can just flip the relevant bits without any problems from
  this turning a NaN into an infinity.

* For the m68k version of ldbl-96, where the high mantissa bit is
  "don't care" for infinities and NaNs, representations where it
  differs must compare the same.  Note: although the testcase for this
  compiles, I have not actually tested on m68k.

* For ldbl-128ibm, the low part must be ignored when the high part is
  NaN, and low parts of +0 and -0 must be considered the same whatever
  the high part.

The new tests in libm-test.inc are the first tests there specifying
particular payloads for input NaNs.  Separate tests are also added for
the ldbl-96 and ldbl-128ibm special cases where there are different
representations of the same value that must compare equal (which can't
be covered in libm-test.inc as that only specifies values, not
representations).

Tested for x86_64, x86, mips64 and powerpc.

	* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(totalorder): New declaration.
	* math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (totalorder):
	New macro.
	* math/Versions (totalorder): New libm symbol at version
	GLIBC_2.25.
	(totalorderf): Likewise.
	(totalorderl): Likewise.
	* math/Makefile (libm-calls): Add s_totalorderF.
	* math/gen-libm-test.pl (parse_args): Escape quotes in test name
	string.
	* math/libm-test.inc (PAYLOAD_DIG): New macro.
	(qnan_value_pl): Likewise.
	(snan_value_pl): Likewise.
	(qnan_value): Define using qnan_value_pl.
	(snan_value): Define using snan_value_pl.
	(struct test_ff_i_data): Add comment about which tests use this
	structure.
	(RUN_TEST_ff_b): New macro.
	(RUN_TEST_LOOP_ff_b): Likewise.
	(totalorder_test_data): New array.
	(totalorder_test): New function.
	(main): Call totalorder_test.
	* math/test-tgmath.c (NCALLS): Increase to 122.
	(F(compile_test)): Call totalorder.
	(F(totalorder)): New function.
	* manual/arith.texi (FP Comparison Functions): Document
	totalorder, totalorderf and totalorderl.
	* manual/libm-err-tab.pl: Update comment on interfaces without
	ulps tabulated.
	* sysdeps/ieee754/dbl-64/s_totalorder.c: New file.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c: Likewise.
	* sysdeps/ieee754/flt-32/s_totalorderf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_totalorderl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_totalorderl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_totalorderl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-totalorder.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
	totalorder.
	(CFLAGS-nldbl-totalorder.c): New variable.
	* sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c: New
	file.
	* sysdeps/ieee754/ldbl-128ibm/Makefile [$(subdir) = math] (tests):
	Add test-totalorderl-ldbl-128ibm.
	* sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c: New file.
	* sysdeps/ieee754/ldbl-96/Makefile [$(subdir) = math] (tests): Add
	test-totalorderl-ldbl-96.
	* sysdeps/nacl/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2016-10-12 01:20:30 +00:00
Paul E. Murphy d4cf133100 Improve gen-libm-test.pl LIT() application
When bootstrapping float128, this exposed a number of areas where
the L suffix is incorrectly applied to simple expressions when it
should be applied to each constant in the expression.

In order to stave off more macros in libm-test.inc, apply_lit is
made slightly more intelligent.  It will now split expressions
based on space characters, and attempt to apply LIT() to each
token.

Having done this, there are numerous spacing issues within
libm-test.inc which have been fixed.

The above is problematic when the L real suffix is not the most
expressive modifier, and the compiler complains (i.e ppc64) or
silently truncates a value (i.e ppc64).
2016-08-05 14:38:57 -05:00
Joseph Myers 7ed84b89f3 Add more sNaN tests (most remaining real functions).
This patch adds tests of sNaN inputs to more functions to
libm-test.inc.  This covers the remaining real functions except for
scalb, where there's a bug to fix, and hypot pow fmin fmax, where
there are cases where a qNaN input does not result in a qNaN output
and so sNaN support according to TS 18661-1 is more of a new feature.

Tested for x86_64 and x86.

	* math/libm-test.inc (snan_value_ld): New macro.
	(isgreater_test_data): Add sNaN tests.
	(isgreaterequal_test_data): Likewise.
	(isless_test_data): Likewise.
	(islessequal_test_data): Likewise.
	(islessgreater_test_data): Likewise.
	(isunordered_test_data): Likewise.
	(nextafter_test_data): Likewise.
	(nexttoward_test_data): Likewise.
	(remainder_test_data): Likewise.
	(remquo_test_data): Likewise.
	(significand_test_data): Likewise.
	* math/gen-libm-test.pl (%beautify): Add snan_value_ld.
2016-06-23 21:59:34 +00:00
Paul E. Murphy 9c665e085f Remove CHOOSE() macro from libm-tests.inc
Use gen-libm-test.pl to generate a list of macros
mapping to libm-test-ulps.h as this simplifies adding new
types without having to modify a growing number of
static headers each time a type is added.

This also removes the final usage of the TEST_(DOUBLE|FLOAT|LDOUBLE)
macros.  Thus, they too are removed.
2016-06-08 14:37:15 -05:00
Paul E. Murphy 8938513484 Apply LIT(x) to floating point literals in libm-test.c
With the exception of the second argument of nexttoward,
any suffixes should be stripped from the test input, and
the macro LIT(x) should be applied to use the correct
suffix for the type being tested.

This adds a new argument type "j" to gen-test-libm.pl
to signify an argument to a test input which does not
require fixup.  The test cases of nexttoward have
been updated to use this new feature.

This applies post-processing to all of the test inputs
through gen-libm-test.pl to strip literal suffixes and
apply the LIT(x) macro, with one exception stated above.
This seems a bit cleaner than tossing the macro onto
everything, albeit slightly more obfuscated.
2016-06-08 14:28:25 -05:00
Joseph Myers 262112840c Support sNaN testing in libm-test.inc.
This patch adds support in libm-test.inc for tests with signaling NaN
arguments.  gen-libm-test.pl is made to set a flag TEST_SNAN for such
tests, so that they can be disabled automatically when sNaN testing
isn't supported for a given type (at present, for float and double on
32-bit x86 because it's unpredictable when a value might be loaded
into a floating-point register and so automatically converted to long
double with sNaNs converted to quiet NaNs).  -fsignaling-nans is used
where needed.

Tests are added for classification macros, as a starting point; this
is deliberately more conservative than Thomas's patch
<https://sourceware.org/ml/libc-ports/2013-04/msg00008.html>, to allow
more tests to be added, and issues exposed fixed, bit by bit.

Tested for x86_64 and x86.

	* math/libm-test.inc: Update comment about NaN testing.
	(TEST_SNAN): New macro.
	(snan_value): Likewise.
	(enable_test): Disable tests of sNaNs when SNAN_TESTS fails.
	(fpclassify_test_data): Add sNaN tests.
	(isfinite_test_data): Likewise.
	(isinf_test_data): Likewise.
	(isnan_test_data): Likewise.
	(isnormal_test_data): Likewise.
	(issignaling_test_data): Likewise.
	(signbit_test_data): Likewise.
	* math/gen-libm-test.pl (%beautify): Add snan_value.
	(show_exceptions): Add argument $test_snan.
	(parse_args): Handle snan_value as non-finite.  Update call to
	show_exceptions.
	* math/Makefile (libm-test-no-inline-cflags): Add
	-fsignaling-nans.
2016-05-26 16:38:04 +00:00
Joseph Myers 2e3d0de31f Fix ulps regeneration for *-finite tests.
On running tests after from-scratch ulps regeneration, I found that
some libm tests failed with ulps in excess of those recorded in the
from-scratch regeneration, which should never happen unless those ulps
exceed the limit on ulps that can go in libm-test-ulps files.

Failure: Test: atan2_upward (inf, -inf)
Result:
 is:          2.35619498e+00   0x1.2d97ccp+1
 should be:   2.35619450e+00   0x1.2d97c8p+1
 difference:  4.76837159e-07   0x1.000000p-21
 ulp       :  2.0000
 max.ulp   :  1.0000
Maximal error of `atan2_upward'
 is      : 2 ulp
 accepted: 1 ulp
Failure: Test: carg_upward (-inf + inf i)
Result:
 is:          2.35619498e+00   0x1.2d97ccp+1
 should be:   2.35619450e+00   0x1.2d97c8p+1
 difference:  4.76837159e-07   0x1.000000p-21
 ulp       :  2.0000
 max.ulp   :  1.0000
Maximal error of `carg_upward'
 is      : 2 ulp
 accepted: 1 ulp

The problem comes from the addition of tests for the finite-math-only
versions of libm functions.  Those tests share ulps with the default
function variants.  make regen-ulps runs the default tests before the
finite-math-only tests, concatenating the resulting ulps before
feeding them to gen-libm-test.pl to generate a new libm-test-ulps
file.  But gen-libm-test.pl always takes the last ulps value given for
any (function, type) pair.  So, if the largest ulps for a function
come from non-finite inputs, a from-scratch regeneration loses those
ulps.

This patch fixes gen-libm-test.pl, in the case where there are
multiple ulps values for a (function, type) pair - which can only
happen as part of a regeneration - to take the largest ulps value
rather than the last one.

Tested for ARM / MIPS / powerpc-nofpu.

	* math/gen-libm-test.pl (parse_ulps): Do not reduce
	already-recorded ulps.
	* sysdeps/arm/libm-test-ulps: Regenerated.
	* sysdeps/mips/mips32/libm-test-ulps: Likewise.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
	* sysdeps/powerpc/nofpu/libm-test-ulps: Likewise.
2016-01-19 21:42:58 +00:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Joseph Myers 5a28590adf Run libm-test tests for finite-math-only functions.
This patch arranges for the libm-test tests to be run for the
finite-math-only function variants, in addition to the existing runs
for out-of-line and bits/mathinline.h inline variants.

gen-libm-test.pl is made to add a flag to all tests with non-finite
inputs or outputs so that they can be skipped at runtime when the
finite-math-only variants are being tested (skipping is for all
rounding modes; that is, -ffinite-math-only is being treated as
excluding overflow cases even when the rounding mode is such that the
overflowed result is finite).  errno setting is not tested for these
variants (in general they don't set it, and it's
implementation-defined in ISO C whether it's set on underflow, with
the glibc definition being that it may not be for -ffinite-math-only;
other cases where errno would normally be expected to be set are
mostly excluded as having non-finite or overflowing arguments or
results).

As with the inline function tests, these ones are built with
-D__FINITE_MATH_ONLY=1 to select the function variants, rather than
-ffinite-math-only.  Use of -ffinite-math-only would not be suitable
for these tests because it would also affect libm-test.inc code that
e.g. tests whether results are infinities or NaNs - if these function
variants have bugs that incorrectly produce such results, we want them
to show up in the tests, which means the compiler should not be
optimizing the tests on the basis of results being finite.

The finite-math-only functions share the same ulps settings as the
main out-of-line functions.

These interfaces were one significant group of untested ABIs listed at
<https://sourceware.org/ml/libc-alpha/2013-07/msg00386.html>.  I
haven't rerun the script to list untested interfaces, but I expect
that the vast bulk of interfaces there are still untested and could do
with testcases being added (or, if applicable, being made compat
symbols; in general, most symbols not starting '_' are safe bets to
add tests for, while _* need more investigation of what the actual
public API is, if any).  I'd like to encourage people to help reduce
the accumulation of untested interfaces by adding more tests.

Tested for x86_64 and x86.  Given my recent lgamma/gamma and log*
fixes, the new tests pass (before those fixes, the new tests showed up
those bugs, so illustrating the practical utility of having tests for
these function variants).

	* math/libm-test.inc (NON_FINITE): New macro.
	(enable_test): Do not run tests flagged NON_FINITE if TEST_FINITE.
	* math/gen-libm-test.pl (show_exceptions): Add argument
	$non_finite.
	(parse_args): Update call to show_exceptions.
	* math/test-math-finite.h: New file.
	* math/test-math-no-finite.h: Likewise.
	* math/test-double-finite.c: Likewise.
	* math/test-float-finite.c: Likewise.
	* math/test-ldouble-finite.c: Likewise.
	* math/test-double.c: Include "test-math-no-finite.h".
	* math/test-float.c: Include "test-math-no-finite.h".
	* math/test-ldouble.c: Include "test-math-no-finite.h".
	* math/test-math-inline.h (TEST_FINITE): New macro.
	* math/test-math-vector.h (TEST_FINITE): Likewise.
	* math/Makefile (test-longdouble-yes): Add test-ldouble-finite.
	(libm-tests): Add test-float-finite and test-double-finite.
	($(objpfx)test-float-finite.o): New dependency on
	$(objpfx)libm-test.stmp.
	($(objpfx)test-double-finite.o): Likewise.
	($(objpfx)test-ldouble-finite.o): Likewise.
	(libm-test-no-inline-cflags): New variable.
	(libm-test-finite-cflags): Likewise.
	(CFLAGS-test-float-finite.c): Likewise.
	(CFLAGS-test-double-finite.c): Likewise.
	(CFLAGS-test-ldouble-finite.c): Likewise.
	(CFLAGS-test-float.c): Use $(libm-test-no-inline-cflags).
	(CFLAGS-test-double.c): Likewise.
	(CFLAGS-test-ldouble.c): Likewise.
2015-11-05 23:28:16 +00:00
Joseph Myers b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Joseph Myers 863893ec95 Test cpow in all rounding modes.
This patch enables testing of cpow in all rounding modes using
ALL_RM_TEST.  There were two reasons this was previously deferred:

* MPC has complicated rounding-mode-dependent rules for the signs of
  exact zero real or imaginary parts in the result of mpc_pow.  Annex
  G does not impose any such requirements and I don't think glibc
  should try to implement any particular logic here.  This patch adds
  support for gen-auto-libm-tests passing the IGNORE_ZERO_INF_SIGN
  flag to libm-test.inc.

* Error accumulations in some tests in non-default rounding modes
  exceed the maximum error permitted in libm-test.inc.  This patch
  marks the problem tests with xfail-rounding.  (It might be possible
  to reduce the accumulations a bit by using round-to-nearest when
  cpow calls clog, but I don't think there's much point; the
  implementation approach for cpow is fundamentally deficient, as
  discussed in the existing bug for cpow inaccuracy which can
  reasonably be considered to cover these less-inaccurate cases as
  well.  It's possible that the test "cpow 2 0 10 0" will also need
  xfail-rounding on some platforms.)

Tested x86_64 and x86 and ulps updated accordingly.

	* math/gen-auto-libm-tests.c: Document use of
	ignore-zero-inf-sign.
	(input_flag_type): Add value flag_ignore_zero_inf_sign.
	(input_flags): Add ignore-zero-inf-sign.
	(output_for_one_input_case): Handle flag_ignore_zero_inf_sign.
	* math/gen-libm-test.pl (generate_testfile): Handle
	ignore-zero-inf-sign.
	* math/auto-libm-test-in: Mark some cpow tests with
	ignore-zero-inf-sign and some with xfail-rounding.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (cpow_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-06-23 20:15:14 +00:00
Joseph Myers 8795b4a443 Set errno for scalb errors (bug 6803, bug 6804).
This patch fixes the default mode of scalb to set errno (bugs 6803 and
6804).

Previously, the _LIB_VERSION == _SVID_ mode would set errno but only
in some relevant cases, and with various peculiarities (such as errno
setting when an exact infinity or zero result arises with an argument
to scalb being an infinity).  This patch leaves this mode
bug-compatible, while making the default mode set errno in accordance
with normal practice (so an exact infinity from an infinite argument
is not an error, and nor is an exact zero result).  gen-libm-test.pl
is taught new notation such as ERRNO_PLUS_OFLOW to facilitate writing
the tests of errno setting for underflow / overflow in libm-test.inc.

Note that bug 6803 also covers scalbn and scalbln, but this patch only
addresses the scalb parts of that bug (along with the whole of bug
6804).

Tested x86_64 and x86.

	[BZ #6803]
	[BZ #6804]
	* math/w_scalb.c (__scalb): For non-SVID mode, check result and
	set errno as appropriate.
	* math/w_scalbf.c (__scalbf): Likewise.
	* math/w_scalbl.c (__scalbl): Likewise.
	* math/gen-libm-test.pl (parse_args): Handle ERRNO_PLUS_OFLOW,
	ERRNO_MINUS_OFLOW, ERRNO_PLUS_UFLOW and ERRNO_MINUS_UFLOW.
	* math/libm-test.inc (scalb_test_data): Add errno expectations.
	Add more NaN tests.
2014-03-31 14:57:53 +00:00
Joseph Myers ae3a5dff0f Make libm-test support ALL_RM_TEST with AUTO_TESTS_*.
This patch continues improvements to all-rounding-mode libm testing by
making testing with ALL_RM_TEST support test results from
auto-libm-test-out.  gen-libm-test.pl is adapted to generate
appropriate output with results for each rounding mode, with
AUTO_TESTS_* calls no longer specifying a rounding mode.  Where there
were separate functions in libm-test.inc to test a function in each
rounding mode, using AUTO_TESTS_* to list the tests for each rounding
mode, those are converted to using ALL_RM_TEST (so generally this
patch doesn't change the sets of tests run in each rounding mode,
except that in various cases special-case tests given directly in
libm-test.inc were previously run only for round-to-nearest, and now
are run for all rounding modes).

Tested x86_64 and x86.

	* math/gen-libm-test.pl (generate_testfile): Expect only function
	name as argument to AUTO_TESTS_* and pass results for all rounding
	modes to parse_args.
	(parse_auto_input): Separate inputs of automatic tests from
	outputs before storing in %auto_tests.
	* math/libm-test.inc (acos_test_data): Update call to
	AUTO_TESTS_f_f.
	(acos_test): Use ALL_RM_TEST.
	(acos_tonearest_test_data): Remove.
	(acos_test_tonearest): Likewise.
	(acos_towardzero_test_data): Likewise.
	(acos_test_towardzero): Likewise.
	(acos_downward_test_data): Likewise.
	(acos_test_downward): Likewise.
	(acos_upward_test_data): Likewise.
	(acos_test_upward): Likewise.
	(acosh_test_data): Update call to AUTO_TESTS_f_f.
	(asin_test_data): Likewise.
	(asin_test): Use ALL_RM_TEST.
	(asin_tonearest_test_data): Remove.
	(asin_test_tonearest): Likewise.
	(asin_towardzero_test_data): Likewise.
	(asin_test_towardzero): Likewise.
	(asin_downward_test_data): Likewise.
	(asin_test_downward): Likewise.
	(asin_upward_test_data): Likewise.
	(asin_test_upward): Likewise.
	(asinh_test_data): Update call to AUTO_TESTS_f_f.
	(atan_test_data): Likewise.
	(atanh_test_data): Likewise.
	(atan2_test_data): Update call to AUTO_TESTS_ff_f.
	(cabs_test_data): Update call to AUTO_TESTS_c_f.
	(carg_test_data): Likewise.
	(cbrt_test_data): Update call to AUTO_TESTS_f_f.
	(ccos_test_data): Update call to AUTO_TESTS_c_c.
	(ccosh_test_data): Likewise.
	(cexp_test_data): Likewise.
	(clog_test_data): Likewise.
	(clog10_test_data): Likewise.
	(cos_test_data): Update call to AUTO_TESTS_f_f.
	(cos_test): Use ALL_RM_TEST.
	(cos_tonearest_test_data): Remove.
	(cos_test_tonearest): Likewise.
	(cos_towardzero_test_data): Likewise.
	(cos_test_towardzero): Likewise.
	(cos_downward_test_data): Likewise.
	(cos_test_downward): Likewise.
	(cos_upward_test_data): Likewise.
	(cos_test_upward): Likewise.
	(cosh_test_data): Update call to AUTO_TESTS_f_f.
	(cosh_test): Use ALL_RM_TEST.
	(cosh_tonearest_test_data): Remove.
	(cosh_test_tonearest): Likewise.
	(cosh_towardzero_test_data): Likewise.
	(cosh_test_towardzero): Likewise.
	(cosh_downward_test_data): Likewise.
	(cosh_test_downward): Likewise.
	(cosh_upward_test_data): Likewise.
	(cosh_test_upward): Likewise.
	(cpow_test_data): Update call to AUTO_TESTS_cc_c.
	(csqrt_test_data): Update call to AUTO_TESTS_c_c.
	(ctan_test_data): Likewise.
	(ctan_test): Use ALL_RM_TEST.
	(ctan_tonearest_test_data): Remove.
	(ctan_test_tonearest): Likewise.
	(ctan_towardzero_test_data): Likewise.
	(ctan_test_towardzero): Likewise.
	(ctan_downward_test_data): Likewise.
	(ctan_test_downward): Likewise.
	(ctan_upward_test_data): Likewise.
	(ctan_test_upward): Likewise.
	(ctanh_test_data): Update call to AUTO_TESTS_c_c.
	(ctanh_test): Use ALL_RM_TEST.
	(ctanh_tonearest_test_data): Remove.
	(ctanh_test_tonearest): Likewise.
	(ctanh_towardzero_test_data): Likewise.
	(ctanh_test_towardzero): Likewise.
	(ctanh_downward_test_data): Likewise.
	(ctanh_test_downward): Likewise.
	(ctanh_upward_test_data): Likewise.
	(ctanh_test_upward): Likewise.
	(erf_test_data): Update call to AUTO_TESTS_f_f.
	(erfc_test_data): Likewise.
	(exp_test_data): Likewise.
	(exp_test): Use ALL_RM_TEST.
	(exp_tonearest_test_data): Remove.
	(exp_test_tonearest): Likewise.
	(exp_towardzero_test_data): Likewise.
	(exp_test_towardzero): Likewise.
	(exp_downward_test_data): Likewise.
	(exp_test_downward): Likewise.
	(exp_upward_test_data): Likewise.
	(exp_test_upward): Likewise.
	(exp10_test_data): Update call to AUTO_TESTS_f_f.
	(exp10_test): Use ALL_RM_TEST.
	(exp10_tonearest_test_data): Remove.
	(exp10_test_tonearest): Likewise.
	(exp10_towardzero_test_data): Likewise.
	(exp10_test_towardzero): Likewise.
	(exp10_downward_test_data): Likewise.
	(exp10_test_downward): Likewise.
	(exp10_upward_test_data): Likewise.
	(exp10_test_upward): Likewise.
	(exp2_test_data): Update call to AUTO_TESTS_f_f.
	(expm1_test_data): Likewise.
	(expm1_test): Use ALL_RM_TEST.
	(expm1_tonearest_test_data): Remove.
	(expm1_test_tonearest): Likewise.
	(expm1_towardzero_test_data): Likewise.
	(expm1_test_towardzero): Likewise.
	(expm1_downward_test_data): Likewise.
	(expm1_test_downward): Likewise.
	(expm1_upward_test_data): Likewise.
	(expm1_test_upward): Likewise.
	(fma_test_data): Update call to AUTO_TESTS_fff_f.
	(fma_test): Use ALL_RM_TEST.
	(fma_towardzero_test_data): Remove.
	(fma_test_towardzero): Likewise.
	(fma_downward_test_data): Likewise.
	(fma_test_downward): Likewise.
	(fma_upward_test_data): Likewise.
	(fma_test_upward): Likewise.
	(hypot_test_data): Update call to AUTO_TESTS_ff_f.
	(j0_test_data): Update call to AUTO_TESTS_f_f.
	(j1_test_data): Likewise.
	(jn_test_data): Update call to AUTO_TESTS_if_f.
	(lgamma_test_data): Update call to AUTO_TESTS_f_f1.
	(log_test_data): Update call to AUTO_TESTS_f_f.
	(log10_test_data): Likewise.
	(log1p_test_data): Likewise.
	(log2_test_data): Likewise.
	(pow_test_data): Update call to AUTO_TESTS_ff_f.
	(pow_tonearest_test_data): Likewise.
	(sin_test_data): Update call to AUTO_TESTS_f_f.
	(sin_test): Use ALL_RM_TEST.
	(sin_tonearest_test_data): Remove.
	(sin_test_tonearest): Likewise.
	(sin_towardzero_test_data): Likewise.
	(sin_test_towardzero): Likewise.
	(sin_downward_test_data): Likewise.
	(sin_test_downward): Likewise.
	(sin_upward_test_data): Likewise.
	(sin_test_upward): Likewise.
	(sincos_test_data): Update call to AUTO_TESTS_fFF_11.
	(sinh_test_data): Update call to AUTO_TESTS_f_f.
	(sinh_test): Use ALL_RM_TEST.
	(sinh_tonearest_test_data): Remove.
	(sinh_test_tonearest): Likewise.
	(sinh_towardzero_test_data): Likewise.
	(sinh_test_towardzero): Likewise.
	(sinh_downward_test_data): Likewise.
	(sinh_test_downward): Likewise.
	(sinh_upward_test_data): Likewise.
	(sinh_test_upward): Likewise.
	(sqrt_test_data): Update call to AUTO_TESTS_f_f.
	(sqrt_test): Use ALL_RM_TEST.
	(sqrt_tonearest_test_data): Remove.
	(sqrt_test_tonearest): Likewise.
	(sqrt_towardzero_test_data): Likewise.
	(sqrt_test_towardzero): Likewise.
	(sqrt_downward_test_data): Likewise.
	(sqrt_test_downward): Likewise.
	(sqrt_upward_test_data): Likewise.
	(sqrt_test_upward): Likewise.
	(tan_test_data): Update call to AUTO_TESTS_f_f.
	(tan_test): Use ALL_RM_TEST.
	(tan_tonearest_test_data): Remove.
	(tan_test_tonearest): Likewise.
	(tan_towardzero_test_data): Likewise.
	(tan_test_towardzero): Likewise.
	(tan_downward_test_data): Likewise.
	(tan_test_downward): Likewise.
	(tan_upward_test_data): Likewise.
	(tan_test_upward): Likewise.
	(tanh_test_data): Update call to AUTO_TESTS_f_f.
	(tgamma_test_data): Likewise.
	(y0_test_data): Likewise.
	(y1_test_data): Likewise.
	(yn_test_data): Update call to AUTO_TESTS_if_f.
	(main): Do not call removed functions.
2014-03-20 11:48:07 +00:00
Joseph Myers b29b6bb8fe Test scalbn and scalbln in all rounding modes, add more tests of negative arguments.
Continuing the move to systematically testing libm functions in all
rounding modes with ALL_RM_TEST, this patch converts the tests of
scalbn and scalbln to use that macro.

Those tests include cases of underflow and overflow, meaning the
expected results depend on the rounding mode.  For convenience in
writing such tests manually, the patch adds the notation plus_oflow,
minus_oflow, plus_uflow and minus_uflow for overflowing / underflowing
results of each sign appropriate to the rounding mode being used, and
gen-libm-test.pl is made to substitute in the appropriate values.  The
tests of underflow and overflow are extended to include negative
arguments to provide better coverage (otherwise minus_oflow and
minus_uflow wouldn't have been used at all).

(A subsequent patch will make ldexp use the scalbn tests, as those
functions are equivalent for binary floating point.)

Tested x86_64 and x86.

	* math/gen-libm-test.pl (parse_args): Handle plus_oflow,
	minus_oflow, plus_uflow and minus_uflow in expected results.
	* math/libm-test.inc (scalbn_test_data): Add more tests of
	negative arguments.  Use plus_oflow, minus_oflow, plus_uflow and
	minus_uflow.
	(scalbn_test): Use ALL_RM_TEST.
	(scalbln_test_data): Add more tests of negative arguments.  Use
	plus_oflow, minus_oflow, plus_uflow and minus_uflow.
	(scalbln_test): Use ALL_RM_TEST.
2014-03-18 18:47:46 +00:00
Joseph Myers 9962a2d34e Add libm-test support for per-rounding-mode manually specified results.
This patch continues the libm-test move towards automatic testing of
all test inputs in all rounding modes by adding gen-libm-test.pl
support for tests specifying results in each rounding mode manually.

Previously a TEST_* line could specify arguments and results, or
arguments, results and flags.  Now there is the option of (arguments,
results-rd, flags-rd, results-rn, flags-rn, results-rz, flags-rz,
results-ru, flags-ru).  This is used to replace the separate arrays of
results in each rounding mode for lrint, llrint and rint.  (In the
case of rint, some tests were only in rint_test_data and needed to
have expectations for non-default rounding modes added, which I did
manually.  In various cases there were slight differences in things
such as the ordering of tests in the arrays for each mode.)

Tested x86_64 and x86.

	* math/gen-libm-test.pl (parse_args): Handle results specified for
	each rounding mode separately.
	* math/libm-test.inc (lrint_test_data): Merge in per-rounding-mode
	tests and results from lrint_tonearest_test_data,
	lrint_towardzero_test_data, lrint_downward_test_data and
	lrint_upward_test_data.
	(lrint_test): Use ALL_RM_TEST.
	(lrint_tonearest_test_data): Remove.
	(lrint_test_tonearest): Likewise.
	(lrint_towardzero_test_data): Likewise.
	(lrint_test_towardzero): Likewise.
	(lrint_downward_test_data): Likewise.
	(lrint_test_downward): Likewise.
	(lrint_upward_test_data): Likewise.
	(lrint_test_upward): Likewise.
	(llrint_test_data): Merge in per-rounding-mode tests and results
	from llrint_tonearest_test_data, llrint_towardzero_test_data,
	llrint_downward_test_data and llrint_upward_test_data.
	(llrint_test): Use ALL_RM_TEST.
	(llrint_tonearest_test_data): Remove.
	(llrint_test_tonearest): Likewise.
	(llrint_towardzero_test_data): Likewise.
	(llrint_test_towardzero): Likewise.
	(llrint_downward_test_data): Likewise.
	(llrint_test_downward): Likewise.
	(llrint_upward_test_data): Likewise.
	(llrint_test_upward): Likewise.
	(rint_test_data): Merge in per-rounding-mode tests and results
	from rint_tonearest_test_data, rint_towardzero_test_data,
	rint_downward_test_data and rint_upward_test_data.  Add
	per-rounding-mode results for tests not in those arrays.
	(rint_test): Use ALL_RM_TEST.
	(rint_tonearest_test_data): Remove.
	(rint_test_tonearest): Likewise.
	(rint_towardzero_test_data): Likewise.
	(rint_test_towardzero): Likewise.
	(rint_downward_test_data): Likewise.
	(rint_test_downward): Likewise.
	(rint_upward_test_data): Likewise.
	(rint_test_upward): Likewise.
	(main): Don't call removed functions.
2014-03-17 12:29:26 +00:00
Joseph Myers 215db4029e Prepare libm-test.inc structures for multi-rounding-mode testing.
At present, libm-test.inc tests are run in multiple rounding modes by
having a separate array for each rounding mode (which might or might
not have the same test inputs as the other such arrays), a separate
function calling a RUN_TEST_LOOP_* macro over that array, and a
separate call to that function in main.  The number of functions
tested in multiple rounding modes has gradually increased as
rounding-mode-specific bugs have been found and fixed in different
functions.

It would be better to be able to use a single macro call, in a single
function, to run tests for a function over all rounding modes, with
this being done for all libm functions except in cases where it's
deferred until some bugs can be fixed because XFAILing all affected
tests would be painful (that's why the full set of pow tests isn't
currently run in all rounding modes).  This patch helps prepare for
that by making the structures storing expected results for tests store
results for all four rounding modes.  After this patch, the results
for all modes are just duplicates, but tests access the appropriate
field in the structure, so helping to pave the way for when the fields
stop being duplicates and multiple rounding modes can be tested from a
single array.  Tests might in future specify a single set of results,
to be used in all rounding modes; separate results for each rounding
mode, specified manually; or use of auto-libm-tests-* to generate
results for each rounding mode.

Tested x86_64.

	* math/libm-test.inc (struct test_f_f_data): Move expected results
	into structure for each rounding mode.
	(struct test_ff_f_data): Likewise.
	(struct test_ff_f_data_nexttoward): Likewise.
	(struct test_fi_f_data): Likewise.
	(struct test_fl_f_data): Likewise.
	(struct test_if_f_data): Likewise.
	(struct test_fff_f_data): Likewise.
	(struct test_c_f_data): Likewise.
	(struct test_f_f1_data): Likewise.
	(struct test_fF_f1_data): Likewise.
	(struct test_ffI_f1_data): Likewise.
	(struct test_c_c_data): Likewise.
	(struct test_cc_c_data): Likewise.
	(struct test_f_i_data): Likewise.
	(struct test_ff_i_data): Likewise.
	(struct test_f_l_data): Likewise.
	(struct test_f_L_data): Likewise.
	(struct test_fFF_11_data): Likewise.
	(RM_): New macro.
	(RM_FE_DOWNWARD): Likewise.
	(RM_FE_TONEAREST): Likewise.
	(RM_FE_TOWARDZERO): Likewise.
	(RM_FE_UPWARD): Likewise.
	(RUN_TEST_LOOP_f_f): Update references to expected results.
	(RUN_TEST_LOOP_2_f): Likewise.
	(RUN_TEST_LOOP_fff_f): Likewise.
	(RUN_TEST_LOOP_c_f): Likewise.
	(RUN_TEST_LOOP_f_f1): Likewise.
	(RUN_TEST_LOOP_fF_f1): Likewise.
	(RUN_TEST_LOOP_fI_f1): Likewise.
	(RUN_TEST_LOOP_ffI_f1): Likewise.
	(RUN_TEST_LOOP_c_c): Likewise.
	(RUN_TEST_LOOP_cc_c): Likewise.
	(RUN_TEST_LOOP_f_i): Likewise.
	(RUN_TEST_LOOP_f_i_tg): Likewise.
	(RUN_TEST_LOOP_ff_i_tg): Likewise.
	(RUN_TEST_LOOP_f_b): Likewise.
	(RUN_TEST_LOOP_f_b_tg): Likewise.
	(RUN_TEST_LOOP_f_l): Likewise.
	(RUN_TEST_LOOP_f_L): Likewise.
	(RUN_TEST_LOOP_fFF_11): Likewise.
	* math/gen-libm-test.pl (parse_args): Output four copies of
	expected results for each test.
2014-03-06 14:15:00 +00:00
Joseph Myers aa97dee16e Adjust how gen-auto-libm-tests handles before-rounding/after-rounding cases.
This patch changes gen-auto-libm-tests so that, when generating test
results that depend on whether the architecture has before-rounding or
after-rounding tininess detection, the :before-rounding or
:after-rounding conditions go on the exception / errno flags
generated, rather than generating two separate lines in
auto-libm-test-out for e.g. flt-32:before-rounding and
flt-32:after-rounding.

The rationale for this is as follows.  It would be desirable for
testing a libm function in all rounding modes to require just one
function and array in libm-test.inc, not four (or five), with the
array of test data including expected results for all rounding modes
rather than separate arrays for each rounding mode that also need to
repeat all the test inputs.  For gen-libm-test.pl to generate data for
such an array from auto-libm-test-out, it would be helpful if each
(format, test input) pair has exactly four lines in
auto-libm-test-out, one for each rounding mode, rather than some
rounding modes having just one line and some having two because the
exceptions depend on tininess detection.

Tested x86_64 and x86.

	* math/gen-auto-libm-tests.c: Update comment on output format.
	(output_for_one_input_case): Generate before-rounding and
	after-rounding information as conditions on output flags not
	floating-point format.
	* math/auto-libm-test-out: Regenerated.
	* math/gen-libm-test.pl (cond_value): New function.
	(or_cond_value): Use cond_value.
	(generate_testfile): Handle conditional exceptions.
2014-03-06 14:11:19 +00:00
Joseph Myers e6b6a85705 Don't include individual test ulps in libm-test-ulps.
As recently discussed
<https://sourceware.org/ml/libc-alpha/2014-02/msg00670.html>, it
doesn't seem particularly useful for libm-test-ulps files to contain
huge amounts of data on ulps for individual tests; just the global
maximum observed ulps for each function, together with the
verification of exceptions, errno and special results such as
infinities and NaNs for each test, suffices to verify that a
function's behavior on the given test inputs is within the expected
accuracy.  Removing this data reduces source tree churn caused by
updates to these files when libm tests are added, and reduces the
frequency with which testsuite additions actually need libm-test-ulps
changes at all.

Accordingly, this patch removes that data, so that individual tests
get checked against the global bounds for the given function and only
generate an error if those are exceeded.  Tested x86_64 (including
verifying that if an ulps value is artificially reduced, the tests do
indeed fail as they should and "make regen-ulps" generates the
expected changes).

	* math/libm-test.inc (struct ulp_data): Don't refer to ulps for
	individual tests in comment.
	(libm-test-ulps.h): Don't refer to test_ulps in #include comment.
	(prev_max_error): New variable.
	(prev_real_max_error): Likewise.
	(prev_imag_max_error): Likewise.
	(compare_ulp_data): Don't refer to test names in comment.
	(find_test_ulps): Remove function.
	(find_function_ulps): Likewise.
	(find_complex_function_ulps): Likewise.
	(init_max_error): Take function name as argument.  Look up ulps
	for that function.
	(print_ulps): Remove function.
	(print_max_error): Use prev_max_error instead of calling
	find_function_ulps.
	(print_complex_max_error): Use prev_real_max_error and
	prev_imag_max_error instead of calling find_complex_function_ulps.
	(check_float_internal): Take max_ulp parameter instead of calling
	find_test_ulps.  Don't call print_ulps.
	(check_float): Update call to check_float_internal.
	(check_complex): Update calls to check_float_internal.
	(START): Pass argument to init_max_error.
	* math/gen-libm-test.pl (%results): Don't include "kind"
	information.
	(parse_ulps): Don't handle ulps of individual tests.
	(print_ulps_file): Likewise.
	(output_ulps): Likewise.
	* math/README.libm-test: Update.
	* manual/libm-err-tab.pl (parse_ulps): Don't handle ulps of
	individual tests.
	* sysdeps/aarch64/libm-test-ulps: Remove individual test ulps.
	* sysdeps/alpha/fpu/libm-test-ulps: Likewise.
	* sysdeps/arm/libm-test-ulps: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/ia64/fpu/libm-test-ulps: Likewise.
	* sysdeps/m68k/coldfire/fpu/libm-test-ulps: Likewise.
	* sysdeps/m68k/m680x0/fpu/libm-test-ulps: Likewise.
	* sysdeps/microblaze/libm-test-ulps: Likewise.
	* sysdeps/mips/mips32/libm-test-ulps: Likewise.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
	* sysdeps/powerpc/fpu/libm-test-ulps: Likewise.
	* sysdeps/powerpc/nofpu/libm-test-ulps: Likewise.
	* sysdeps/s390/fpu/libm-test-ulps: Likewise.
	* sysdeps/sh/libm-test-ulps: Likewise.
	* sysdeps/sparc/fpu/libm-test-ulps: Likewise.
	* sysdeps/tile/libm-test-ulps: Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.

	* sysdeps/hppa/fpu/libm-test-ulps: Remove individual test ulps.
2014-03-05 15:02:38 +00:00
Andreas Schwab 1c0d11bce5 Let gen-libm-test.pl find itself when run outside source directory 2014-01-27 18:43:22 +01:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Joseph Myers 335ee09231 Disable libm-test test name beautification for M_* constants.
math/gen-libm-test.pl has code to beautify names of various constants,
transforming the source form in libm-test.inc into the version
appearing in test names in libm-test-ulps files.

This has become decreasingly relevant over time for the M_* constants,
first as I changed the test names so only the arguments and not the
expected results appeared in them, then as tests have moved to
auto-libm-test-* so that automatically generated hex float constants
get used instead of M_* in test inputs.

This patch removes the beautification for all M_* constants.  Tested
x86_64 and x86 and ulps updated accordingly.  Even the one case where
this affected the name in the ulps files will disappear once complex
function tests are moved to auto-libm-test-*.

	* math/gen-libm-test.pl (%beautify): Remove M_* constants.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2013-12-19 14:59:22 +00:00
Joseph Myers ffb536d0ac Start generating libm tests automatically with MPFR. 2013-11-29 16:27:55 +00:00
Joseph Myers ce66581742 Test signs of NaNs in libm-test.inc where appropriate. 2013-11-16 12:48:35 +00:00
Joseph Myers ee1466a953 Add libm-test support for ignored return value, add more lrint / llrint / lround / llround tests. 2013-11-16 12:47:38 +00:00
Joseph Myers 14407b7e60 Replace libm-test.inc TEST_INLINE conditionals with NO_TEST_INLINE flag. 2013-11-16 12:46:52 +00:00
Joseph Myers e8bdba36c5 Remove libm-test START_DATA and END_DATA. 2013-05-24 13:10:42 +00:00
Joseph Myers b679a606ca Make libm-test START and END into ordinary macros. 2013-05-24 12:22:04 +00:00
Joseph Myers 351fe55087 Don't include function names in test data in generated libm-test.c. 2013-05-22 21:01:44 +00:00
Joseph Myers b50a71810b Don't include expected results in libm-test test names. 2013-05-22 11:49:36 +00:00
Joseph Myers db62a90753 Handle sincos with generic libm-test logic. 2013-05-19 14:45:41 +00:00
Joseph Myers f16cc3eb81 Simplify gen-libm-test.pl handling of tests with extra outputs. 2013-05-19 14:40:40 +00:00
Joseph Myers 3779b5b64a Make libm-test look up ulps by name at runtime. 2013-05-18 12:10:59 +00:00
Joseph Myers a00bdcf0e0 Simplify libm-test extra-output initialization. 2013-05-17 19:02:19 +00:00
Joseph Myers 323e5cb792 Remove libm-test support for TEST_* inside functions. 2013-05-16 19:09:03 +00:00
Joseph Myers 081988778f Convert TEST_c_c tests from code to data. 2013-05-12 17:38:26 +00:00
Joseph Myers 51df539d98 Start converting libm tests from code to data. 2013-05-10 16:45:04 +00:00
Joseph Myers f44bf14a9c Move some libm-test logic for running tests from gen-libm-test.pl to libm-test.inc. 2013-05-08 12:02:22 +00:00
Joseph Myers 9ea3513c91 Initialize x in frexp, modf, remqou tests. 2013-05-06 20:23:40 +00:00
Joseph Myers b7dab1e4d7 Remove unused libm-test expected-failure mechanism. 2013-05-04 16:45:15 +00:00
Joseph Myers f2da779309 Integrate errno testing better in libm-test.inc. 2013-04-29 20:36:48 +00:00
Thomas Schwinge 572676160d New <math.h> macro named issignaling to check for a signaling NaN (sNaN).
It is based on draft TS 18661 and currently enabled as a GNU extension.
2013-04-02 13:51:02 +02:00
Thomas Schwinge bdef0be784 libm-test: Properly wrap blocks consisting of several statements. 2013-03-21 16:07:48 +01:00
Thomas Schwinge 67e971f18f Better distinguish between NaN/qNaN/sNaN. 2013-03-15 19:06:02 +01:00
Joseph Myers 568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Joseph Myers 0e8e0c1c93 Make libm-test.inc test comparison macros. 2012-10-09 23:34:12 +00:00