From patchwork Tue Nov 17 11:15:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 56783 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1866955lbb; Tue, 17 Nov 2015 03:16:15 -0800 (PST) X-Received: by 10.66.249.37 with SMTP id yr5mr61801218pac.24.1447758974913; Tue, 17 Nov 2015 03:16:14 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id sf2si57484934pbc.162.2015.11.17.03.16.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2015 03:16:14 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-65017-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libc-alpha-return-65017-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-65017-patch=linaro.org@sourceware.org; dkim=pass header.i=@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=lOtD2YT9n8voRdYa0GoQILJuEty2N ApAk3Ri58EKmig5Vkqwbuq/+hWAMJSUgCD6EZLpwHtyCMSOCnOBLYLVVfl9PWNW7 DUAEWFgTC5ppqm84cuweUh1a8sH6hTnSz6cG0mWU9kFkMc+Tq/R7cc1Nrrur3kY0 B4HDKRrR91Cof4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=p4PVgIlxNp6my80Ug/rYDc2ogyM=; b=FYf FViEyHkRzvyn6pKIwlsPVbRpIbK2t+oHEGq+vvRqRDPe4ELbTWKc9rtfvO/LVEwy Ly434ttpm+LbA5fLwIn0CvDF1vIMo1ZWFiLP81KhmboaYOwF31h2qMC/gcDupSlz /FEP7Mh4ygyayWklBH6IdpgG/o+JAUI505e05MKQ= Received: (qmail 16213 invoked by alias); 17 Nov 2015 11:16:06 -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 16202 invoked by uid 89); 17 Nov 2015 11:16:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f54.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=FnY3iEhdIq07tBrt5UMqk7XQdyrBv9w2N5NIny/pNo8=; b=moDIdjYsWLNvYJsbfX+Srfw6m+UHeBYzNJ7yprDUjqAEZlE6/LnOcY98XK6y9R7rh4 KMvAhTEWdpzYUJ3/G3g558H4EFodVD3W7t0m0ylZqAIrO28eeE4Z19SxQtvHXGVUbbUI uGkSYjRQJQ8qFS2ETs8qnJZYSC0ZrpCvEFeVq+9KsIE+mjZGozohWCPqw/S56pELn4cK MteeTfN2NGubdMKkxWpelidtXhD4gOt7jKQhIkmvJEBoUdndFOH9MU7YCmf2v+RsmYDd Wd+OQhunCO+Ts9ZZuhC4V9YqTkgd2R7h86BqYzUqFNpAnEg3kUjWpoMxHhFc2VtgV68n BfXQ== X-Gm-Message-State: ALoCoQn6Qa0ALSnVmKv2+O3+x+I9tz3PKs703onJ+GeG2OIHfYF/D3vNUWoYU7xKXG76X/HrhUHs X-Received: by 10.66.193.36 with SMTP id hl4mr10522234pac.153.1447758962370; Tue, 17 Nov 2015 03:16:02 -0800 (PST) Date: Tue, 17 Nov 2015 16:45:57 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [PATCH] Include s_sin.c in s_sincos.c Message-ID: <20151117111557.GA27201@linaro-laptop.intra.reserved-bit.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Include the __sin and __cos functions as local static copies to allow deper optimization of the functions. This change shows an improvement of about 17% in the min case and 12.5% in the mean case for the sincos microbenchmark on x86_64. Siddhesh * sysdeps/ieee754/dbl-64/s_sin.c (__sin)[IN_SINCOS]: Mark function static and don't set or restore rounding. (__cos)[IN_SINCOS]: Likewise. * sysdeps/ieee754/dbl-64/s_sincos.c: Include s_sin.c. (__sincos): Set and restore rounding mode. Remove check for infinite or NaN input. --- sysdeps/ieee754/dbl-64/s_sin.c | 12 ++++++++++++ sysdeps/ieee754/dbl-64/s_sincos.c | 25 +++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) -- 2.4.3 diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c index b8d49e2..a635a86 100644 --- a/sysdeps/ieee754/dbl-64/s_sin.c +++ b/sysdeps/ieee754/dbl-64/s_sin.c @@ -280,8 +280,12 @@ reduce_and_compute (double x, unsigned int k) /* An ultimate sin routine. Given an IEEE double machine number x */ /* it computes the correctly rounded (to nearest) value of sin(x) */ /*******************************************************************/ +#ifdef IN_SINCOS +static double +#else double SECTION +#endif __sin (double x) { double xx, res, t, cor, y, s, c, sn, ssn, cs, ccs, xn, a, da, db, eps, xn1, @@ -290,7 +294,9 @@ __sin (double x) int4 k, m, n; double retval = 0; +#ifndef IN_SINCOS SET_RESTORE_ROUND_53BIT (FE_TONEAREST); +#endif u.x = x; m = u.i[HIGH_HALF]; @@ -512,8 +518,12 @@ __sin (double x) /* it computes the correctly rounded (to nearest) value of cos(x) */ /*******************************************************************/ +#ifdef IN_SINCOS +static double +#else double SECTION +#endif __cos (double x) { double y, xx, res, t, cor, xn, a, da, db, eps, xn1, @@ -523,7 +533,9 @@ __cos (double x) double retval = 0; +#ifndef IN_SINCOS SET_RESTORE_ROUND_53BIT (FE_TONEAREST); +#endif u.x = x; m = u.i[HIGH_HALF]; diff --git a/sysdeps/ieee754/dbl-64/s_sincos.c b/sysdeps/ieee754/dbl-64/s_sincos.c index d7431b7..2a3fc06 100644 --- a/sysdeps/ieee754/dbl-64/s_sincos.c +++ b/sysdeps/ieee754/dbl-64/s_sincos.c @@ -22,29 +22,18 @@ #include +#define __sin __sin_local +#define __cos __cos_local +#define IN_SINCOS 1 +#include "s_sin.c" void __sincos (double x, double *sinx, double *cosx) { - int32_t ix; + SET_RESTORE_ROUND_53BIT (FE_TONEAREST); - /* High word of x. */ - GET_HIGH_WORD (ix, x); - - /* |x| ~< pi/4 */ - ix &= 0x7fffffff; - if (ix >= 0x7ff00000) - { - /* sin(Inf or NaN) is NaN */ - *sinx = *cosx = x - x; - if (isinf (x)) - __set_errno (EDOM); - } - else - { - *sinx = __sin (x); - *cosx = __cos (x); - } + *sinx = __sin (x); + *cosx = __cos (x); } weak_alias (__sincos, sincos) #ifdef NO_LONG_DOUBLE