This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[Patch] Fix cexpl when compiled with latest GCC
- From: Steve Ellcey <sellcey at cavium dot com>
- To: carlos at redhat dot com, libc-alpha at sourceware dot org, nd at arm dot com, siddhesh at sourceware dot org, Wilco dot Dijkstra at arm dot com
- Date: Thu, 20 Jul 2017 16:01:56 -0700
- Subject: [Patch] Fix cexpl when compiled with latest GCC
- Authentication-results: sourceware.org; auth=none
- Reply-to: sellcey at cavium dot com
While testing glibc on aarch64 and building with the latest GCC (Top-of-tree)
I got several failures involving the long double exp function. (See
https://sourceware.org/ml/libc-alpha/2017-07/msg00704.html) The underflow
exception was getting raised where it should not be.
GCC does not know that moving floating point operations around the fesetenv
call can change the flag settings and glibc deals with this by using the
math_force_eval and math_opt_barrier macros to restrict GCC optimizations.
This patch adds a call to math_force_eval so that the multiplication that
creates x22 is completed before the fesetenv call and thus the underflow
exception that is generated by the expression does not get raised (it is
wiped out by the call to fesetenv). That is the behavour that we want and
what glibc is doing when compiled with older compilers.
OK to checkin? Is this something we want in for 2.26 or should it wait
until after the release?
Steve Ellcey
sellcey@cavium.com
2017-07-20 Steve Ellcey <sellcey@cavium.com>
* sysdeps/ieee754/ldbl-128/e_expl.c (__ieee754_expl): Call
math_force_eval.
diff --git a/sysdeps/ieee754/ldbl-128/e_expl.c b/sysdeps/ieee754/ldbl-128/e_expl.c
index 15639d1..fd7700c 100644
--- a/sysdeps/ieee754/ldbl-128/e_expl.c
+++ b/sysdeps/ieee754/ldbl-128/e_expl.c
@@ -192,6 +192,7 @@ __ieee754_expl (_Float128 x)
with maximum error in [-2^-16-2^-53,2^-16+2^-53]
less than 4.8e-39. */
x22 = x + x*x*(P1+x*(P2+x*(P3+x*(P4+x*(P5+x*P6)))));
+ math_force_eval (x22);
/* Return result. */
fesetenv (&oldenv);