From patchwork Tue Dec 5 17:37:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 24742 Received: (qmail 69490 invoked by alias); 5 Dec 2017 17:37:47 -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 69479 invoked by uid 89); 5 Dec 2017 17:37:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f169.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DiaI3cj9xxK2iDB7+7CePH5h08QvR0nbvyGUbVwXEcE=; b=U3FfnGGShR1SLV2sAmDHspmFGs+6EJClwprhAL/BSw5GxT5fQabm9UFdkwBVTqs3Qd aaR55HgS2t9Fh+rZy3QQKN71F52zUF1WwDZvh9f7QHoXWnaEFQFg9ctEN+LNTxAMlXst GxLdk4F9rJaelq0J09T1C8J3UuF5mnGLEB9C29jgFf78sZZXDsHbjph96XQs6KcFIAV1 nkPPUWoDezJshT4IdeZuaCQqyv9graJ6UaO3fJk0tZ77hothUjt42UFnTi8HMvZSnWyq 5cBMNY1GjXDks+Y++yC7kHBWd5XGEAoC9chu3mwfCxA8LdEG4siPc/wB9K5AUFxII7I6 g8aQ== X-Gm-Message-State: AKGB3mIYO1q19Msn0TcyysIyM6Gmbmep8cSEqJ91oFMRNSbbcPPON4iY wm5+eBykxHJzC3yIhgrv4NvsnQvVOZU= X-Google-Smtp-Source: AGs4zMYznqImtsAJV6Z1InduWnss6PjUETWEFCvS9p1iAQ0B2LIs6tGu1lunZzZKz1rn7k8M66Yy8w== X-Received: by 10.237.59.202 with SMTP id s10mr2596144qte.294.1512495463795; Tue, 05 Dec 2017 09:37:43 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH] math: Use sign as double for reduced case in sinf Date: Tue, 5 Dec 2017 15:37:36 -0200 Message-Id: <1512495456-10490-1-git-send-email-adhemerval.zanella@linaro.org> This patch avoid an extra floating point to integer conversion in reduced internal function for generic sinf by defining the sign as double instead of integers. There is no much difference on Haswell with GCC 7.2.1: Before After min 9.11 9.108 mean 21.982 21.9224 However H.J. Lu reported gains on Skylake: Before: "sinf": { "": { "duration": 3.4044e+10, "iterations": 1.9942e+09, "max": 141.106, "min": 7.704, "mean": 17.0715 } } After: "sinf": { "": { "duration": 3.40665e+10, "iterations": 2.03199e+09, "max": 95.994, "min": 7.704, "mean": 16.765 } } Checked on x86_64-linux-gnu. * sysdeps/ieee754/flt-32/s_sinf.c (ones): Define as double. (reduced): Use ones as double instead of integer. --- ChangeLog | 5 +++++ sysdeps/ieee754/flt-32/s_sinf.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sysdeps/ieee754/flt-32/s_sinf.c b/sysdeps/ieee754/flt-32/s_sinf.c index 0b76477..05edd48 100644 --- a/sysdeps/ieee754/flt-32/s_sinf.c +++ b/sysdeps/ieee754/flt-32/s_sinf.c @@ -75,7 +75,7 @@ static const double invpio4_table[] = { 0x1.0e4107cp-169 }; -static const int ones[] = { +1, -1 }; +static const double ones[] = { 1.0, -1.0 }; /* Compute the sine value using Chebyshev polynomials where THETA is the range reduced absolute value of the input @@ -92,7 +92,7 @@ reduced (const double theta, const unsigned int n, const double theta2 = theta * theta; /* We are operating on |x|, so we need to add back the original signbit for sinf. */ - int sign; + double sign; /* Determine positive or negative primary interval. */ sign = ones[((n >> 2) & 1) ^ signbit]; /* Are we in the primary interval of sin or cos? */