From patchwork Thu Jul 20 23:01:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 21713 Received: (qmail 3868 invoked by alias); 20 Jul 2017 23:02:08 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 3850 invoked by uid 89); 20 Jul 2017 23:02:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=x22, 1926, Hx-languages-length:1587 X-Spam-User: qpsmtpd, 2 recipients X-HELO: camailhost.cavium.com Date: Thu, 20 Jul 2017 16:01:56 -0700 From: Steve Ellcey Message-Id: <201707202301.v6KN1uY2012836@sellcey-dt.caveonetworks.com> To: carlos@redhat.com, libc-alpha@sourceware.org, nd@arm.com, siddhesh@sourceware.org, Wilco.Dijkstra@arm.com Subject: [Patch] Fix cexpl when compiled with latest GCC Reply-To: sellcey@cavium.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 * 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);