glibc/sysdeps/ieee754/flt-32
Joseph Myers 548cc83c38 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.

(cherry picked from commit f124cb3811)
2017-09-28 02:03:21 +00:00
..
e_acosf.c
e_acoshf.c
e_asinf.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_atan2f.c
e_atanhf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_coshf.c Avoid excess range overflowing results from cosh, sinh, lgamma (bug 18980). 2015-09-18 20:00:48 +00:00
e_exp2f.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_expf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_fmodf.c
e_gammaf_r.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_hypotf.c Fix hypot sNaN handling (bug 20940). 2016-12-07 01:16:36 +00:00
e_ilogbf.c
e_j0f.c Fix y0 and y1 exception handling for zero input [BZ #21134] 2017-02-15 10:30:59 -02:00
e_j1f.c Fix y0 and y1 exception handling for zero input [BZ #21134] 2017-02-15 10:30:59 -02:00
e_jnf.c Fix j1, jn missing errno setting on underflow (bug 18611). 2015-10-23 21:37:33 +00:00
e_lgammaf_r.c Narrowing the visibility of libc-internal.h even further. 2017-03-01 20:33:46 -05:00
e_log2f.c Fix lgamma*, log10* and log2* results [BZ #21171] 2017-02-17 09:07:57 -02:00
e_log10f.c Fix lgamma*, log10* and log2* results [BZ #21171] 2017-02-17 09:07:57 -02:00
e_logf.c
e_powf.c Optimized version of powf() 2017-06-23 09:19:17 -03:00
e_rem_pio2f.c Improve float range reduction accuracy near pi/2 (bug 21094). 2017-03-15 22:00:54 +00:00
e_remainderf.c
e_sinhf.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_sqrtf.c
k_cosf.c
k_rem_pio2f.c Narrowing the visibility of libc-internal.h even further. 2017-03-01 20:33:46 -05:00
k_sinf.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
k_tanf.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
lgamma_negf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
lgamma_productf.c Fix lgamma (negative) inaccuracy (bug 2542, bug 2543, bug 2558). 2015-09-10 22:27:58 +00:00
mpn2flt.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_asinhf.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_atanf.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_cbrtf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_ceilf.c Do not raise "inexact" from generic ceil (bug 15479). 2016-05-24 17:42:10 +00:00
s_copysignf.c
s_cosf.c Fix several build failures with GCC6 due to unused static variables. 2015-09-18 20:42:54 +01:00
s_erff.c Work around powerpc32 integer 0 converting to -0 (bug 887, bug 19049, bug 19050). 2015-10-05 17:46:50 +00:00
s_expm1f.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_fabsf.c 2015-05-28 Wilco Dijkstra <wdijkstr@arm.com> 2015-05-28 11:42:55 +01:00
s_finitef.c Reduce number of constants in __finite* (bug 15384). 2015-09-17 16:47:14 +00:00
s_floorf.c Do not raise "inexact" from generic floor (bug 15479). 2016-05-24 17:44:46 +00:00
s_fpclassifyf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_frexpf.c Fix frexp (NaN) (bug 20250). 2016-06-13 17:27:19 +00:00
s_fromfpf_main.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_fromfpf.c Add fromfp functions. 2016-12-31 00:40:59 +00:00
s_fromfpxf.c Add fromfp functions. 2016-12-31 00:40:59 +00:00
s_getpayloadf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_isinff.c
s_isnanf.c
s_issignalingf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_llrintf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_llroundf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_log1pf.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_logbf.c Work around powerpc32 integer 0 converting to -0 (bug 887, bug 19049, bug 19050). 2015-10-05 17:46:50 +00:00
s_lrintf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_lroundf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_modff.c
s_nearbyintf.c Fix nearbyint arithmetic moved before feholdexcept (bug 22225). 2017-09-28 02:03:21 +00:00
s_nextafterf.c Make nextafter, nexttoward set errno (bug 6799). 2015-11-02 18:54:19 +00:00
s_nextupf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_remquof.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_rintf.c
s_roundevenf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_roundf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_scalblnf.c
s_scalbnf.c Make scalbn set errno (bug 6803). 2015-09-16 21:11:00 +00:00
s_setpayloadf_main.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_setpayloadf.c Add setpayload, setpayloadf, setpayloadl. 2016-11-19 00:16:28 +00:00
s_setpayloadsigf.c Add setpayloadsig, setpayloadsigf, setpayloadsigl. 2016-11-24 23:56:48 +00:00
s_signbitf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_sincosf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_sinf.c
s_tanf.c
s_tanhf.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_totalorderf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_totalordermagf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_truncf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_ufromfpf.c Add fromfp functions. 2016-12-31 00:40:59 +00:00
s_ufromfpxf.c Add fromfp functions. 2016-12-31 00:40:59 +00:00
t_exp2f.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
w_expf_compat.c Move w_exp to libm-compat-call-auto 2017-02-08 17:44:20 -02:00