glibc/sysdeps/ieee754/dbl-64/wordsize-64
Joseph Myers f124cb3811 Fix nearbyint arithmetic moved before feholdexcept (bug 22225).
In <https://sourceware.org/ml/libc-alpha/2013-05/msg00722.html> I
remarked on the possibility of arithmetic in various nearbyint
implementations being scheduled before feholdexcept calls, resulting
in spurious "inexact" exceptions.

I'm now actually observing this occurring in glibc built for ARM with
GCC 7 (in fact, both copies of the same addition/subtraction sequence
being combined and moved out before the conditionals and
feholdexcept/fesetenv pairs), resulting in test failures.

This patch makes the nearbyint implementations with this particular
feholdexcept / arithmetic / fesetenv pattern consistently use
math_opt_barrier on the function argument when first used in
arithmetic, and also consistently use math_force_eval before fesetenv
(the latter was generally already done, but the dbl-64/wordsize-64
implementation used math_opt_barrier instead, and as
math_opt_barrier's intended effect is through its output value being
used, such a use that doesn't use the return value is suspect).

Tested for x86_64 (--disable-multi-arch so more of these
implementations get used), and for ARM in a configuration where I saw
the problem scheduling.

	[BZ #22225]
	* sysdeps/ieee754/dbl-64/s_nearbyint.c (__nearbyint): Use
	math_opt_barrier on argument when doing arithmetic on it.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c (__nearbyint):
	Likewise.  Use math_force_eval not math_opt_barrier after
	arithmetic.
	* sysdeps/ieee754/flt-32/s_nearbyintf.c (__nearbyintf): Use
	math_opt_barrier on argument when doing arithmetic on it.
	* sysdeps/ieee754/ldbl-128/s_nearbyintl.c (__nearbyintl):
	Likewise.
2017-09-28 01:59:02 +00:00
..
e_acosh.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_cosh.c Fix expm1 missing underflows (bug 16353). 2015-06-22 21:06:19 +00:00
e_fmod.c Add #include <stdint.h> for uint[32|64]_t usage (except installed headers). 2013-05-16 11:32:54 -05:00
e_log2.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
e_log10.c Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
s_ceil.c Do not raise "inexact" from generic ceil (bug 15479). 2016-05-24 17:42:10 +00:00
s_finite.c Fix __finitel libm compat symbol version. 2016-01-20 19:04:43 +00:00
s_floor.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_frexp.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_getpayload.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
s_isinf.c math: add LDBL_CLASSIFY_COMPAT support 2015-12-03 13:00:46 -05:00
s_isnan.c math: add LDBL_CLASSIFY_COMPAT support 2015-12-03 13:00:46 -05:00
s_issignaling.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
s_llround.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_logb.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_lround.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_modf.c Add #include <stdint.h> for uint[32|64]_t usage (except installed headers). 2013-05-16 11:32:54 -05:00
s_nearbyint.c Fix nearbyint arithmetic moved before feholdexcept (bug 22225). 2017-09-28 01:59:02 +00:00
s_remquo.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_rint.c Clean up dbl-64 rint, nearbyint. 2012-03-13 14:12:44 +00:00
s_round.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_roundeven.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
s_scalbln.c [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
s_scalbn.c Make scalbn set errno (bug 6803). 2015-09-16 21:11:00 +00:00
s_setpayload_main.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_totalorder.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
s_totalordermag.c Make more libm functions into weak aliases. 2017-09-14 22:28:53 +00:00
s_trunc.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00