glibc/sysdeps
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
..
aarch64 Optimized generic expf and exp2f with wrappers 2017-09-25 10:44:39 +01:00
alpha Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
arm Enable unwind info in libc-start.c and backtrace.c 2017-09-19 15:07:58 +01:00
generic Define and use libm_alias_float128. 2017-09-14 01:11:46 +00:00
gnu hurd: Fix getifaddrs' and freeifaddrs' symbol exposition 2017-09-28 01:05:18 +02:00
hppa Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
i386 Optimized generic expf and exp2f with wrappers 2017-09-25 10:44:39 +01:00
ia64 Fix ia64 executable stack default (bug 22156). 2017-09-26 16:30:46 +00:00
ieee754 Fix nearbyint arithmetic moved before feholdexcept (bug 22225). 2017-09-28 01:59:02 +00:00
init_array Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
m68k Optimized generic expf and exp2f with wrappers 2017-09-25 10:44:39 +01:00
mach hurd: Fix seekdir' symbol exposition from rewinddir' 2017-09-28 00:49:59 +02:00
microblaze Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
mips Enable unwind info in libc-start.c and backtrace.c 2017-09-19 15:07:58 +01:00
nios2 Enable unwind info in libc-start.c and backtrace.c 2017-09-19 15:07:58 +01:00
nptl Remove extra semicolons in struct pthread_mutex (bug 21804) 2017-07-24 12:22:05 +02:00
posix hurd: Fix dirfd symbol exposition from ftw 2017-09-28 00:49:05 +02:00
powerpc powerpc: Regenerate ULPs for expf() and exp2f() 2017-09-26 16:13:33 -03:00
pthread aio: Remove internal_function function attribute 2017-08-31 15:59:06 +02:00
s390 Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
sh Enable unwind info in libc-start.c and backtrace.c 2017-09-19 15:07:58 +01:00
sparc Use generic __ifunc for SPARC. 2017-09-26 19:49:33 +00:00
tile Obsolete pow10 functions. 2017-09-01 21:13:18 +00:00
unix Update sysdeps/unix/sysv/linux/ifaddrs.c 2017-09-27 17:18:32 -07:00
wordsize-32 Build divdi3 only for architecture that required it 2017-04-06 15:14:34 -03:00
wordsize-64 posix: Consolidate Linux glob implementation 2017-09-08 16:34:02 +02:00
x86 x86: Add MathVec_Prefer_No_AVX512 to cpu-features [BZ #21967] 2017-09-12 07:54:47 -07:00
x86_64 Add SSE4.1 trunc, truncf (bug 20142). 2017-09-20 16:54:05 +00:00