From patchwork Tue Nov 17 11:14:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 56782 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1866434lbb; Tue, 17 Nov 2015 03:15:08 -0800 (PST) X-Received: by 10.66.164.196 with SMTP id ys4mr15620012pab.119.1447758907966; Tue, 17 Nov 2015 03:15:07 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ud9si7748246pbc.60.2015.11.17.03.15.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2015 03:15:07 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-65016-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-65016-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-65016-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=qycz+Z5sHtv82N1G6m/JDhhhTXIB9 YZg0cJBxJmavwLfRXVJWGKbqSl9HkGuOS5BGhsyU1STwqQuF6Qxc3lXL56UovyWZ 69/N+AYuCIlC09/QNrmV03IwhvcnRilpHrPBXExiOJ1h6IMCIpW6YZ3nF+nM0Exd 3It8sQWCqlBv/c= 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=/h0iDdaPcT5cc9WClLYQIBCJivk=; b=q90 qIe5+8p1W4N7EeT9lEc4sQO+nt2COOZfjaDukrKZeAVtmQ2A6HCnHb2lLMtwujR+ eK0wiY18zmMwjvRCVIvZLYKeHbWVRVMnZA2ixcJIDsnQXUFNmxIpSP9W2S1kXcWY eI3qbEnLziOGPLHVn+A6Cvf3teZrsrN0V0JcHPZE= Received: (qmail 14006 invoked by alias); 17 Nov 2015 11:14:58 -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 13994 invoked by uid 89); 17 Nov 2015 11:14:57 -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-f42.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=LtahxSmYCyC92Rk37lQVtrU2pmmAC/LziFb3mZrBuCM=; b=lFKO7b3Gh8M2HKTPzewP9JyzYPCvtw2QAFCPVjIi6BPkC6H1krBxZcvfUGNR1DuOlR 1zfawvr5ij7ZXPp20MbA/g7kyvACna7JF/gwkvXuqF5Oq77TiRXAUP4RlOz1uMu+g58a hWlidtTvpZbOLSZ3kphvZfHLf/1SRwVou6KguJzCJYLtfIH76nhtCeGkPFB70LjzcXO8 HO0O/myJhN0Z9nkc/Brfb+fSpbJlIk2rUSB2e2798TWRG75vn1+Ak9Yfz7rGW5WVC1bq /w2xvrVAvbnsoqUOm1AuXELPs5aAmHuPx45R4ZPVI30u++HkvhsivyEfwoqMxwWFGFhw hZuw== X-Gm-Message-State: ALoCoQmW24qc4BCyi0eeFEnjvNIaXNmZBN4MtH26j/m6jZm51NefGCEgu1kQwfne8e5m1q11R7cc X-Received: by 10.68.98.97 with SMTP id eh1mr61666163pbb.128.1447758893634; Tue, 17 Nov 2015 03:14:53 -0800 (PST) Date: Tue, 17 Nov 2015 16:44:49 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [COMMITTED] Remove redundant else clauses in s_sin.c Message-ID: <20151117111449.GA27152@linaro-laptop.intra.reserved-bit.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Makes the code easier to read due to the reduced nesting. The generated binary is unchanged. Siddhesh --- ChangeLog | 2 + sysdeps/ieee754/dbl-64/s_sin.c | 350 +++++++++++++++++++---------------------- 2 files changed, 163 insertions(+), 189 deletions(-) -- 2.4.3 diff --git a/ChangeLog b/ChangeLog index 2d53b2b..1d223b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2015-11-17 Siddhesh Poyarekar + * sysdeps/ieee754/dbl-64/s_sin.c: Remove redundant else clauses. + * benchtests/scripts/bench.py (_print_arg_data): Mark output variables as used. diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c index 48c924c..b8d49e2 100644 --- a/sysdeps/ieee754/dbl-64/s_sin.c +++ b/sysdeps/ieee754/dbl-64/s_sin.c @@ -744,14 +744,12 @@ slow (double x) res = TAYLOR_SLOW (x, 0, cor); if (res == res + 1.0007 * cor) return res; - else - { - __dubsin (fabs (x), 0, w); - if (w[0] == w[0] + 1.000000001 * w[1]) - return (x > 0) ? w[0] : -w[0]; - else - return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false); - } + + __dubsin (fabs (x), 0, w); + if (w[0] == w[0] + 1.000000001 * w[1]) + return (x > 0) ? w[0] : -w[0]; + + return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false); } /*******************************************************************************/ @@ -771,14 +769,12 @@ slow1 (double x) res = do_sin_slow (u, y, 0, 0, &cor); if (res == res + cor) return (x > 0) ? res : -res; - else - { - __dubsin (fabs (x), 0, w); - if (w[0] == w[0] + 1.000000005 * w[1]) - return (x > 0) ? w[0] : -w[0]; - else - return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false); - } + + __dubsin (fabs (x), 0, w); + if (w[0] == w[0] + 1.000000005 * w[1]) + return (x > 0) ? w[0] : -w[0]; + + return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false); } /**************************************************************************/ @@ -809,17 +805,15 @@ slow2 (double x) res = do_cos_slow (u, y, del, 0, &cor); if (res == res + cor) return (x > 0) ? res : -res; - else - { - y = fabs (x) - hp0; - y1 = y - hp1; - y2 = (y - y1) - hp1; - __docos (y1, y2, w); - if (w[0] == w[0] + 1.000000005 * w[1]) - return (x > 0) ? w[0] : -w[0]; - else - return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false); - } + + y = fabs (x) - hp0; + y1 = y - hp1; + y2 = (y - y1) - hp1; + __docos (y1, y2, w); + if (w[0] == w[0] + 1.000000005 * w[1]) + return (x > 0) ? w[0] : -w[0]; + + return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false); } /***************************************************************************/ @@ -845,46 +839,42 @@ sloww (double x, double dx, double orig) if (res == res + cor) return res; + + (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w); + if (w[1] > 0) + cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-30; else + cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-30; + + if (w[0] == w[0] + cor) + return (x > 0) ? w[0] : -w[0]; + + t = (orig * hpinv + toint); + xn = t - toint; + v.x = t; + y = (orig - xn * mp1) - xn * mp2; + n = v.i[LOW_HALF] & 3; + da = xn * pp3; + t = y - da; + da = (y - t) - da; + y = xn * pp4; + a = t - y; + da = ((t - a) - y) + da; + if (n & 2) { - (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w); - if (w[1] > 0) - cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-30; - else - cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-30; - - if (w[0] == w[0] + cor) - return (x > 0) ? w[0] : -w[0]; - else - { - t = (orig * hpinv + toint); - xn = t - toint; - v.x = t; - y = (orig - xn * mp1) - xn * mp2; - n = v.i[LOW_HALF] & 3; - da = xn * pp3; - t = y - da; - da = (y - t) - da; - y = xn * pp4; - a = t - y; - da = ((t - a) - y) + da; - if (n & 2) - { - a = -a; - da = -da; - } - (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w); - if (w[1] > 0) - cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-40; - else - cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-40; - - if (w[0] == w[0] + cor) - return (a > 0) ? w[0] : -w[0]; - else - return __mpsin (orig, 0, true); - } + a = -a; + da = -da; } + (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w); + if (w[1] > 0) + cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-40; + else + cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-40; + + if (w[0] == w[0] + cor) + return (a > 0) ? w[0] : -w[0]; + + return __mpsin (orig, 0, true); } /***************************************************************************/ @@ -907,20 +897,18 @@ sloww1 (double x, double dx, double orig, int m) if (res == res + cor) return (m > 0) ? res : -res; + + __dubsin (x, dx, w); + + if (w[1] > 0) + cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig); else - { - __dubsin (x, dx, w); + cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig); - if (w[1] > 0) - cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig); - else - cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig); + if (w[0] == w[0] + cor) + return (m > 0) ? w[0] : -w[0]; - if (w[0] == w[0] + cor) - return (m > 0) ? w[0] : -w[0]; - else - return __mpsin (orig, 0, true); - } + return __mpsin (orig, 0, true); } /***************************************************************************/ @@ -943,20 +931,18 @@ sloww2 (double x, double dx, double orig, int n) if (res == res + cor) return (n & 2) ? -res : res; + + __docos (x, dx, w); + + if (w[1] > 0) + cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig); else - { - __docos (x, dx, w); + cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig); - if (w[1] > 0) - cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig); - else - cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig); + if (w[0] == w[0] + cor) + return (n & 2) ? -w[0] : w[0]; - if (w[0] == w[0] + cor) - return (n & 2) ? -w[0] : w[0]; - else - return __mpsin (orig, 0, true); - } + return __mpsin (orig, 0, true); } /***************************************************************************/ @@ -977,18 +963,17 @@ bsloww (double x, double dx, double orig, int n) cor = (cor > 0) ? 1.0005 * cor + 1.1e-24 : 1.0005 * cor - 1.1e-24; if (res == res + cor) return res; + + (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w); + if (w[1] > 0) + cor = 1.000000001 * w[1] + 1.1e-24; else - { - (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w); - if (w[1] > 0) - cor = 1.000000001 * w[1] + 1.1e-24; - else - cor = 1.000000001 * w[1] - 1.1e-24; - if (w[0] == w[0] + cor) - return (x > 0) ? w[0] : -w[0]; - else - return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true); - } + cor = 1.000000001 * w[1] - 1.1e-24; + + if (w[0] == w[0] + cor) + return (x > 0) ? w[0] : -w[0]; + + return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true); } /***************************************************************************/ @@ -1012,20 +997,18 @@ bsloww1 (double x, double dx, double orig, int n) res = do_sin_slow (u, y, dx, 1.1e-24, &cor); if (res == res + cor) return (x > 0) ? res : -res; + + __dubsin (fabs (x), dx, w); + + if (w[1] > 0) + cor = 1.000000005 * w[1] + 1.1e-24; else - { - __dubsin (fabs (x), dx, w); + cor = 1.000000005 * w[1] - 1.1e-24; - if (w[1] > 0) - cor = 1.000000005 * w[1] + 1.1e-24; - else - cor = 1.000000005 * w[1] - 1.1e-24; + if (w[0] == w[0] + cor) + return (x > 0) ? w[0] : -w[0]; - if (w[0] == w[0] + cor) - return (x > 0) ? w[0] : -w[0]; - else - return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true); - } + return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true); } /***************************************************************************/ @@ -1049,20 +1032,18 @@ bsloww2 (double x, double dx, double orig, int n) res = do_cos_slow (u, y, dx, 1.1e-24, &cor); if (res == res + cor) return (n & 2) ? -res : res; + + __docos (fabs (x), dx, w); + + if (w[1] > 0) + cor = 1.000000005 * w[1] + 1.1e-24; else - { - __docos (fabs (x), dx, w); + cor = 1.000000005 * w[1] - 1.1e-24; - if (w[1] > 0) - cor = 1.000000005 * w[1] + 1.1e-24; - else - cor = 1.000000005 * w[1] - 1.1e-24; + if (w[0] == w[0] + cor) + return (n & 2) ? -w[0] : w[0]; - if (w[0] == w[0] + cor) - return (n & 2) ? -w[0] : w[0]; - else - return (n & 1) ? __mpsin (orig, 0, true) : __mpcos (orig, 0, true); - } + return (n & 1) ? __mpsin (orig, 0, true) : __mpcos (orig, 0, true); } /************************************************************************/ @@ -1083,15 +1064,13 @@ cslow2 (double x) res = do_cos_slow (u, y, 0, 0, &cor); if (res == res + cor) return res; - else - { - y = fabs (x); - __docos (y, 0, w); - if (w[0] == w[0] + 1.000000005 * w[1]) - return w[0]; - else - return __mpcos (x, 0, false); - } + + y = fabs (x); + __docos (y, 0, w); + if (w[0] == w[0] + 1.000000005 * w[1]) + return w[0]; + + return __mpcos (x, 0, false); } /***************************************************************************/ @@ -1120,48 +1099,44 @@ csloww (double x, double dx, double orig) if (res == res + cor) return res; + + (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w); + + if (w[1] > 0) + cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-30; else + cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-30; + + if (w[0] == w[0] + cor) + return (x > 0) ? w[0] : -w[0]; + + t = (orig * hpinv + toint); + xn = t - toint; + v.x = t; + y = (orig - xn * mp1) - xn * mp2; + n = v.i[LOW_HALF] & 3; + da = xn * pp3; + t = y - da; + da = (y - t) - da; + y = xn * pp4; + a = t - y; + da = ((t - a) - y) + da; + if (n == 1) { - (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w); - - if (w[1] > 0) - cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-30; - else - cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-30; - - if (w[0] == w[0] + cor) - return (x > 0) ? w[0] : -w[0]; - else - { - t = (orig * hpinv + toint); - xn = t - toint; - v.x = t; - y = (orig - xn * mp1) - xn * mp2; - n = v.i[LOW_HALF] & 3; - da = xn * pp3; - t = y - da; - da = (y - t) - da; - y = xn * pp4; - a = t - y; - da = ((t - a) - y) + da; - if (n == 1) - { - a = -a; - da = -da; - } - (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w); - - if (w[1] > 0) - cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-40; - else - cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-40; - - if (w[0] == w[0] + cor) - return (a > 0) ? w[0] : -w[0]; - else - return __mpcos (orig, 0, true); - } + a = -a; + da = -da; } + (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w); + + if (w[1] > 0) + cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-40; + else + cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-40; + + if (w[0] == w[0] + cor) + return (a > 0) ? w[0] : -w[0]; + + return __mpcos (orig, 0, true); } /***************************************************************************/ @@ -1184,18 +1159,17 @@ csloww1 (double x, double dx, double orig, int m) if (res == res + cor) return (m > 0) ? res : -res; + + __dubsin (x, dx, w); + if (w[1] > 0) + cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig); else - { - __dubsin (x, dx, w); - if (w[1] > 0) - cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig); - else - cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig); - if (w[0] == w[0] + cor) - return (m > 0) ? w[0] : -w[0]; - else - return __mpcos (orig, 0, true); - } + cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig); + + if (w[0] == w[0] + cor) + return (m > 0) ? w[0] : -w[0]; + + return __mpcos (orig, 0, true); } @@ -1219,18 +1193,16 @@ csloww2 (double x, double dx, double orig, int n) if (res == res + cor) return (n) ? -res : res; + + __docos (x, dx, w); + if (w[1] > 0) + cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig); else - { - __docos (x, dx, w); - if (w[1] > 0) - cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig); - else - cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig); - if (w[0] == w[0] + cor) - return (n) ? -w[0] : w[0]; - else - return __mpcos (orig, 0, true); - } + cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig); + if (w[0] == w[0] + cor) + return (n) ? -w[0] : w[0]; + + return __mpcos (orig, 0, true); } #ifndef __cos