glibc/sysdeps/ieee754/ldbl-128ibm
Joseph Myers d8742dd82f Add narrowing add functions.
This patch adds the narrowing add functions from TS 18661-1 to glibc's
libm: fadd, faddl, daddl, f32addf64, f32addf32x, f32xaddf64 for all
configurations; f32addf64x, f32addf128, f64addf64x, f64addf128,
f32xaddf64x, f32xaddf128, f64xaddf128 for configurations with
_Float64x and _Float128; __nldbl_daddl for ldbl-opt.  As discussed for
the build infrastructure patch, tgmath.h support is deliberately
deferred, and FP_FAST_* macros are not applicable without optimized
function implementations.

Function implementations are added for all relevant pairs of formats
(including certain cases of a format and itself where more than one
type has that format).  The main implementations use round-to-odd, or
a trivial computation in the case where both formats are the same or
where the wider format is IBM long double (in which case we don't
attempt to be correctly rounding).  The sysdeps/ieee754/soft-fp
implementations use soft-fp, and are used automatically for
configurations without exceptions and rounding modes by virtue of
existing Implies files.  As previously discussed, optimized versions
for particular architectures are possible, but not included.

i386 gets a special version of f32xaddf64 to avoid problems with
double rounding (similar to the existing fdim version), since this
function must round just once without an intermediate rounding to long
double.  (No such special version is needed for any other function,
because the nontrivial functions use round-to-odd, which does the
intermediate computation with the rounding mode set to round-to-zero,
and double rounding is OK except in round-to-nearest mode, so is OK
for that intermediate round-to-zero computation.)  mul and div will
need slightly different special versions for i386 (using round-to-odd
on long double instead of precision control) because of the
possibility of inexact intermediate results in the subnormal range for
double.

To reduce duplication among the different function implementations,
math-narrow.h gets macros CHECK_NARROW_ADD, NARROW_ADD_ROUND_TO_ODD
and NARROW_ADD_TRIVIAL.

In the trivial cases and for any architecture-specific optimized
implementations, the overhead of the errno setting might be
significant, but I think that's best handled through compiler built-in
functions rather than providing separate no-errno versions in glibc
(and likewise there are no __*_finite entry points for these function
provided, __*_finite effectively being no-errno versions at present in
most cases).

Tested for x86_64 and x86, with both GCC 6 and GCC 7.  Tested for
mips64 (all three ABIs, both hard and soft float) and powerpc with GCC
7.  Tested with build-many-glibcs.py with both GCC 6 and GCC 7.

	* math/Makefile (libm-narrow-fns): Add add.
	(libm-test-funcs-narrow): Likewise.
	* math/Versions (GLIBC_2.28): Add narrowing add functions.
	* math/bits/mathcalls-narrow.h (add): Use __MATHCALL_NARROW .
	* math/gen-auto-libm-tests.c (test_functions): Add add.
	* math/math-narrow.h (CHECK_NARROW_ADD): New macro.
	(NARROW_ADD_ROUND_TO_ODD): Likewise.
	(NARROW_ADD_TRIVIAL): Likewise.
	* sysdeps/ieee754/float128/float128_private.h (__faddl): New
	macro.
	(__daddl): Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fadd and
	dadd.
	(CFLAGS-nldbl-dadd.c): New variable.
	(CFLAGS-nldbl-fadd.c): Likewise.
	* sysdeps/ieee754/ldbl-opt/Versions (GLIBC_2.28): Add
	__nldbl_daddl.
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__nldbl_daddl): New
	prototype.
	* manual/arith.texi (Misc FP Arithmetic): Document fadd, faddl,
	daddl, fMaddfN, fMaddfNx, fMxaddfN and fMxaddfNx.
	* math/auto-libm-test-in: Add tests of add.
	* math/auto-libm-test-out-narrow-add: New generated file.
	* math/libm-test-narrow-add.inc: New file.
	* sysdeps/i386/fpu/s_f32xaddf64.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_f32xaddf64.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fadd.c: Likewise.
	* sysdeps/ieee754/float128/s_f32addf128.c: Likewise.
	* sysdeps/ieee754/float128/s_f64addf128.c: Likewise.
	* sysdeps/ieee754/float128/s_f64xaddf128.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_daddl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_f64xaddf128.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_faddl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_daddl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_faddl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_daddl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_faddl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-dadd.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-fadd.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_daddl.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_fadd.c: Likewise.
	* sysdeps/ieee754/soft-fp/s_faddl.c: Likewise.
	* sysdeps/powerpc/fpu/libm-test-ulps: Update.
	* sysdeps/mach/hurd/i386/libm.abilist: Likewise.
	* 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/riscv/rv64/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/tilegx32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2018-02-10 02:08:43 +00:00
..
bits Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
include/bits Add canonicalize, canonicalizef, canonicalizel. 2016-10-26 23:14:31 +00:00
Makefile Add canonicalize, canonicalizef, canonicalizel. 2016-10-26 23:14:31 +00:00
e_acoshl.c Fix ldbl-128ibm acoshl inaccuracy (bug 18019). 2015-02-25 00:01:15 +00:00
e_acosl.c This patch renames all uses of __isinf*, __isnan*, __finite* and __signbit* to use standard C99 macros. This has no effect on generated code. 2015-06-03 15:41:36 +01:00
e_asinl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_atan2l.c
e_atanhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_coshl.c
e_exp10l.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
e_expl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
e_fmodl.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_gammal_r.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
e_hypotl.c Fix hypot sNaN handling (bug 20940). 2016-12-07 01:16:36 +00:00
e_ilogbl.c Fix ldbl-128ibm ilogbl near powers of 2 (bug 18029). 2015-02-26 12:57:21 +00:00
e_j0l.c Make some ldbl-128, ldbl-128ibm arrays const. 2017-12-06 13:42:58 +00:00
e_j1l.c Make some ldbl-128, ldbl-128ibm arrays const. 2017-12-06 13:42:58 +00:00
e_jnl.c Fix j1, jn missing errno setting on underflow (bug 18611). 2015-10-23 21:37:33 +00:00
e_lgammal_r.c Use fabs(f/l) rather than __fabs 2017-09-29 18:54:24 +01:00
e_log2l.c Use fabs(f/l) rather than __fabs 2017-09-29 18:54:24 +01:00
e_log10l.c Use fabs(f/l) rather than __fabs 2017-09-29 18:54:24 +01:00
e_logl.c Remove unneeded declarations from math_private.h 2017-04-10 12:20:47 -03:00
e_powl.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_rem_pio2l.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
e_remainderl.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_sinhl.c Fix ldbl-128ibm sinhl spurious overflows (bug 19350). 2015-12-09 22:37:08 +00:00
e_sqrtl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
gamma_productl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
ieee754.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
k_cosl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
k_sincosl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
k_sinl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
k_tanl.c Narrowing the visibility of libc-internal.h even further. 2017-03-01 20:33:46 -05:00
ldbl2mpn.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
lgamma_negl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
lgamma_productl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
math_ldbl.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
mpn2ldbl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
printf_fphex.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_asinhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_atanl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_cbrtl.c ldbl-128ibm: Automatic replacing of _Float128 and L() 2017-09-21 17:37:39 -03:00
s_ceill.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_copysignl.c Remove IS_IN_libm 2014-11-24 11:41:47 +05:30
s_cosl.c
s_daddl.c Add narrowing add functions. 2018-02-10 02:08:43 +00:00
s_erfl.c Remove unused variables 2016-01-27 09:30:16 +01:00
s_expm1l.c Fix ldbl-128ibm expm1l (sNaN) (bug 20233). 2016-06-09 17:24:52 +00:00
s_fabsl.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
s_faddl.c Add narrowing add functions. 2018-02-10 02:08:43 +00:00
s_finitel.c Reduce number of constants in __finite* (bug 15384). 2015-09-17 16:47:14 +00:00
s_floorl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_fmal.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_fpclassifyl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_frexpl.c Fix frexp (NaN) (bug 20250). 2016-06-13 17:27:19 +00:00
s_fromfpl.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
s_fromfpl_main.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_fromfpxl.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
s_getpayloadl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_iscanonicall.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_isinfl.c Remove IS_IN_libm 2014-11-24 11:41:47 +05:30
s_isnanl.c Remove IS_IN_libm 2014-11-24 11:41:47 +05:30
s_issignalingl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_llrintl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_llroundl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_log1pl.c Fix ldbl-128ibm log1pl (-qNaN) spurious "invalid" exception (bug 22693). 2018-01-10 17:59:01 +00:00
s_logbl.c Work around powerpc32 integer 0 converting to -0 (bug 887, bug 19049, bug 19050). 2015-10-05 17:46:50 +00:00
s_lrintl.c Fix ldbl-128ibm lrintl, lroundl missing "invalid" exceptions (bug 22690). 2018-01-10 00:02:35 +00:00
s_lroundl.c Fix ldbl-128ibm lrintl, lroundl missing "invalid" exceptions (bug 22690). 2018-01-10 00:02:35 +00:00
s_modfl.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
s_nearbyintl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_nextafterl.c Fix ldbl-128ibm nextafterl, nexttowardl sign of zero result (bug 19678). 2016-02-19 17:19:53 +00:00
s_nexttoward.c Make nextafter, nexttoward set errno (bug 6799). 2015-11-02 18:54:19 +00:00
s_nexttowardf.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
s_nextupl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_remquol.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_rintl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_roundevenl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_roundl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_scalblnl.c
s_scalbnl.c Make scalbn set errno (bug 6803). 2015-09-16 21:11:00 +00:00
s_setpayloadl.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
s_setpayloadl_main.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_setpayloadsigl.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
s_signbitl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_sincosl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_sinl.c
s_tanhl.c Fix ldbl-128ibm tanhl inaccuracy for small arguments (bug 19349). 2015-12-09 21:20:18 +00:00
s_tanl.c
s_totalorderl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_totalordermagl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_truncl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
s_ufromfpl.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
s_ufromfpxl.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
strtod_nan_ldouble.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
strtold_l.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
t_expl.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
t_sincosl.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
test-canonical-ldbl-128ibm.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
test-fmodl-ldbl-128ibm.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
test-fmodrem-ldbl-128ibm.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
test-remainderl-ldbl-128ibm.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
test-remquol-ldbl-128ibm.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
test-totalorderl-ldbl-128ibm.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
tst-strtold-ldbl-128ibm.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
x2y2m1l.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00