From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30091 invoked by alias); 21 Mar 2018 17:54:30 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 29804 invoked by uid 89); 21 Mar 2018 17:54:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=orig, UD:And, rotates, *************************************************************************** X-HELO: EUR02-VE1-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH 5/7] sin/cos slow paths: remove unused slowpath functions Date: Wed, 21 Mar 2018 17:54:00 -0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB6PR0801MB1813;7:0Ts4mI75D4ZpXIQ/RUkdOTdDZUiEuNxmCuxUN0tDJL21bsm6hXBTg4aMtkq6XsTBaNxfcxdnjUQYrxtzyJgI3hNehlg7CcCcOf0UqFcv/mebNSNu9nvygBgAYoynHHv4ZT9D/mtXJ1gNv4h1qexpamtupcKcFg9GvRwUpSlW5U4kfAcj79LHl+h1CRvzJj2RKs55MUquFbQ/Jvwtb6wsErTQgj6hiXVbuc6wQwfSK0OFO0P9l/MqVWJDqnLQSi+s x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: ba418d96-486a-4ea2-6b01-08d58f54c730 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(2017052603328)(7153060)(7193020);SRVR:DB6PR0801MB1813; x-ms-traffictypediagnostic: DB6PR0801MB1813: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231221)(944501325)(52105095)(93006095)(93001095)(6055026)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DB6PR0801MB1813;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0801MB1813; x-forefront-prvs: 0618E4E7E1 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(376002)(396003)(346002)(39860400002)(39380400002)(199004)(189003)(377424004)(54534003)(102836004)(478600001)(305945005)(8936002)(2351001)(9686003)(3660700001)(7696005)(5660300001)(66066001)(53946003)(86362001)(55016002)(105586002)(6436002)(81166006)(5640700003)(8676002)(53936002)(6916009)(6116002)(106356001)(2900100001)(3280700002)(6506007)(2906002)(81156014)(59450400001)(3846002)(25786009)(4326008)(68736007)(7736002)(99286004)(26005)(5250100002)(2501003)(14454004)(316002)(33656002)(97736004)(72206003)(74316002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0801MB1813;H:DB6PR0801MB2053.eurprd08.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: G0HL77Sd500m9tstwqEfwJx+/TpjZbxOCxUfTEqth+I3kMR8rACATvOGOPh0zhPgJ8DLoLwMn15czJcuec7+8m05V7kSGcH39Q4kloQcbr7EDvePLXuzcMbwxP6PBXuSE0hQzalv2V0bRJdlx5Xa1EcsceT2vW3qqRLf9eJ94W+85KGcA6Z//n57d9XD6GcPdgXRODuYnjIdtJdhwmmEOtb/PGHgEi+I5SLt3FHyPEZwYV6gOZPLfpKMb87XtD8PQSrqSwuEbKNkqnRJPkfdZEQbEE8Uxjb6L7Gq09rCuelyX2JMd202Uu6jCuRKSMUzopZEmdjlmxf3Z1nW3txCWA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba418d96-486a-4ea2-6b01-08d58f54c730 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Mar 2018 17:54:22.4032 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1813 X-SW-Source: 2018-03/txt/msg00508.txt.bz2 Remove all unused slowpath functions. ChangeLog: 2018-03-20 Wilco Dijkstra * sysdeps/ieee754/dbl-64/s_sin.c (TAYLOR_SLOW): Remove. (do_cos_slow): Likewise. (do_sin_slow): Likewise. (reduce_and_compute): Likewise. (slow): Likewise. (slow1): Likewise. (slow2): Likewise. (sloww): Likewise. (sloww1): Likewise. (sloww2): Likewise. (bslow): Likewise. (bslow1): Likewise. (bslow2): Likewise. (cslow2): Likewise. -- diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c index 099a8a128f9883d1e683436a9f09720922e923ce..7a55636889f186849f638c4c510= ee29dd007d655 100644 --- a/sysdeps/ieee754/dbl-64/s_sin.c +++ b/sysdeps/ieee754/dbl-64/s_sin.c @@ -22,22 +22,11 @@ /* = */ /* FUNCTIONS: usin = */ /* ucos = */ -/* slow = */ -/* slow1 = */ -/* slow2 = */ -/* sloww = */ -/* sloww1 = */ -/* sloww2 = */ -/* bsloww = */ -/* bsloww1 = */ -/* bsloww2 = */ -/* cslow2 = */ /* FILES NEEDED: dla.h endian.h mpa.h mydefs.h usncs.h = */ -/* branred.c sincos32.c dosincos.c mpa.c = */ -/* sincos.tbl = */ +/* branred.c sincos.tbl */ /* = */ -/* An ultimate sin and routine. Given an IEEE double machine number x = */ -/* it computes the correctly rounded (to nearest) value of sin(x) or cos(x= ) */ +/* An ultimate sin and cos routine. Given an IEEE double machine number x = */ +/* it computes sin(x) or cos(x) with ~0.55 ULP. */ /* Assumption: Machine arithmetic operations are performed in = */ /* round to nearest mode of IEEE 754 standard. = */ /* = */ @@ -74,29 +63,6 @@ res; \ }) =20 -/* This is again a variation of the Taylor series expansion with the term - x^3/3! expanded into the following for better accuracy: - - bb * x ^ 3 + 3 * aa * x * x1 * x2 + aa * x1 ^ 3 + aa * x2 ^ 3 - - The correction term is dx and bb + aa =3D -1/3! - */ -#define TAYLOR_SLOW(x0, dx, cor) \ -({ \ - static const double th2_36 =3D 206158430208.0; /* 1.5*2**37 */ = \ - double xx =3D (x0) * (x0); \ - double x1 =3D ((x0) + th2_36) - th2_36; \ - double y =3D aa * x1 * x1 * x1; \ - double r =3D (x0) + y; \ - double x2 =3D ((x0) - x1) + (dx); \ - double t =3D (((POLYNOMIAL2 (xx) + bb) * xx + 3.0 * aa * x1 * x2) \ - * (x0) + aa * x2 * x2 * x2 + (dx)); \ - t =3D (((x0) - r) + y) + t; \ - double res =3D r + t; \ - (cor) =3D (r - res) + t; \ - res; \ -}) - #define SINCOS_TABLE_LOOKUP(u, sn, ssn, cs, ccs) \ ({ \ int4 k =3D u.i[LOW_HALF] << 2; \ @@ -123,23 +89,7 @@ static const double cs4 =3D -4.16666666666664434524222570944589E-02, cs6 =3D 1.38888874007937613028114285595617E-03; =20 -static const double t22 =3D 0x1.8p22; - -void __dubsin (double x, double dx, double w[]); -void __docos (double x, double dx, double w[]); -double __mpsin (double x, double dx, bool reduce_range); -double __mpcos (double x, double dx, bool reduce_range); -static double slow (double x); -static double slow1 (double x); -static double slow2 (double x); -static double sloww (double x, double dx, double orig, bool shift_quadrant= ); -static double sloww1 (double x, double dx, double orig, bool shift_quadran= t); -static double sloww2 (double x, double dx, double orig, int n); -static double bsloww (double x, double dx, double orig, int n); -static double bsloww1 (double x, double dx, double orig, int n); -static double bsloww2 (double x, double dx, double orig, int n); int __branred (double x, double *a, double *aa); -static double cslow2 (double x); =20 /* Given a number partitioned into X and DX, this function computes the co= sine of the number by combining the sin and cos of X (as computed by a varia= tion @@ -166,40 +116,6 @@ do_cos (double x, double dx) return cs + cor; } =20 -/* A more precise variant of DO_COS. EPS is the adjustment to the correct= ion - COR. */ -static inline double -__always_inline -do_cos_slow (double x, double dx, double eps, double *corp) -{ - mynumber u; - - if (x <=3D 0) - dx =3D -dx; - - u.x =3D big + fabs (x); - x =3D fabs (x) - (u.x - big); - - double xx, y, x1, x2, e1, e2, res, cor; - double s, sn, ssn, c, cs, ccs; - xx =3D x * x; - s =3D x * xx * (sn3 + xx * sn5); - c =3D x * dx + xx * (cs2 + xx * (cs4 + xx * cs6)); - SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs); - x1 =3D (x + t22) - t22; - x2 =3D (x - x1) + dx; - e1 =3D (sn + t22) - t22; - e2 =3D (sn - e1) + ssn; - cor =3D (ccs - cs * c - e1 * x2 - e2 * x) - sn * s; - y =3D cs - e1 * x1; - cor =3D cor + ((cs - y) - e1 * x1); - res =3D y + cor; - cor =3D (y - res) + cor; - cor =3D 1.0005 * cor + __copysign (eps, cor); - *corp =3D cor; - return res; -} - /* Given a number partitioned into X and DX, this function computes the si= ne of the number by combining the sin and cos of X (as computed by a variatio= n of the Taylor series) with the values looked up from the sin/cos table to = get @@ -224,70 +140,6 @@ do_sin (double x, double dx) return sn + cor; } =20 -/* A more precise variant of DO_SIN. EPS is the adjustment to the correct= ion - COR. */ -static inline double -__always_inline -do_sin_slow (double x, double dx, double eps, double *corp) -{ - mynumber u; - - if (x <=3D 0) - dx =3D -dx; - u.x =3D big + fabs (x); - x =3D fabs (x) - (u.x - big); - - double xx, y, x1, x2, c1, c2, res, cor; - double s, sn, ssn, c, cs, ccs; - xx =3D x * x; - s =3D x * xx * (sn3 + xx * sn5); - c =3D xx * (cs2 + xx * (cs4 + xx * cs6)); - SINCOS_TABLE_LOOKUP (u, sn, ssn, cs, ccs); - x1 =3D (x + t22) - t22; - x2 =3D (x - x1) + dx; - c1 =3D (cs + t22) - t22; - c2 =3D (cs - c1) + ccs; - cor =3D (ssn + s * ccs + cs * s + c2 * x + c1 * x2 - sn * x * dx) - sn *= c; - y =3D sn + c1 * x1; - cor =3D cor + ((sn - y) + c1 * x1); - res =3D y + cor; - cor =3D (y - res) + cor; - cor =3D 1.0005 * cor + __copysign (eps, cor); - *corp =3D cor; - return res; -} - -/* Reduce range of X and compute sin of a + da. When SHIFT_QUADRANT is tru= e, - the routine returns the cosine of a + da by rotating the quadrant once = and - computing the sine of the result. */ -static inline double -__always_inline -reduce_and_compute (double x, bool shift_quadrant) -{ - double retval =3D 0, a, da; - unsigned int n =3D __branred (x, &a, &da); - int4 k =3D (n + shift_quadrant) % 4; - switch (k) - { - case 2: - a =3D -a; - da =3D -da; - /* Fall through. */ - case 0: - if (a * a < 0.01588) - retval =3D bsloww (a, da, x, n); - else - retval =3D bsloww1 (a, da, x, n); - break; - - case 1: - case 3: - retval =3D bsloww2 (a, da, x, n); - break; - } - return retval; -} - /* Reduce range of x to within PI/2 with abs (x) < 105414350. The high pa= rt is written to *a, the low part to *da. Range reduction is accurate to = 136 bits so that when x is large and *a very close to zero, all 53 bits of = *a @@ -508,299 +360,6 @@ __cos (double x) return retval; } =20 -/************************************************************************/ -/* Routine compute sin(x) for 2^-26 < |x|< 0.25 by Taylor with more */ -/* precision and if still doesn't accurate enough by mpsin or dubsin */ -/************************************************************************/ - -static inline double -__always_inline -slow (double x) -{ - double res, cor, w[2]; - res =3D TAYLOR_SLOW (x, 0, cor); - if (res =3D=3D res + 1.0007 * cor) - return res; - - __dubsin (fabs (x), 0, w); - if (w[0] =3D=3D w[0] + 1.000000001 * w[1]) - return __copysign (w[0], x); - - return __copysign (__mpsin (fabs (x), 0, false), x); -} - -/*************************************************************************= ******/ -/* Routine compute sin(x) for 0.25<|x|< 0.855469 by __sincostab.tbl and Ta= ylor */ -/* and if result still doesn't accurate enough by mpsin or dubsin = */ -/*************************************************************************= ******/ - -static inline double -__always_inline -slow1 (double x) -{ - double w[2], cor, res; - - res =3D do_sin_slow (x, 0, 0, &cor); - if (res =3D=3D res + cor) - return res; - - __dubsin (fabs (x), 0, w); - if (w[0] =3D=3D w[0] + 1.000000005 * w[1]) - return w[0]; - - return __mpsin (fabs (x), 0, false); -} - -/*************************************************************************= */ -/* Routine compute sin(x) for 0.855469 <|x|<2.426265 by __sincostab.= tbl */ -/* and if result still doesn't accurate enough by mpsin or dubsin = */ -/*************************************************************************= */ -static inline double -__always_inline -slow2 (double x) -{ - double w[2], y, y1, y2, cor, res; - - double t =3D hp0 - fabs (x); - res =3D do_cos_slow (t, hp1, 0, &cor); - if (res =3D=3D res + cor) - return res; - - y =3D fabs (x) - hp0; - y1 =3D y - hp1; - y2 =3D (y - y1) - hp1; - __docos (y1, y2, w); - if (w[0] =3D=3D w[0] + 1.000000005 * w[1]) - return w[0]; - - return __mpsin (fabs (x), 0, false); -} - -/* Compute sin(x + dx) where X is small enough to use Taylor series around= zero - and (x + dx) in the first or third quarter of the unit circle. ORIG is= the - original value of X for computing error of the result. If the result i= s not - accurate enough, the routine calls mpsin or dubsin. SHIFT_QUADRANT rot= ates - the unit circle by 1 to compute the cosine instead of sine. */ -static inline double -__always_inline -sloww (double x, double dx, double orig, bool shift_quadrant) -{ - double y, t, res, cor, w[2], a, da, xn; - mynumber v; - int4 n; - res =3D TAYLOR_SLOW (x, dx, cor); - - double eps =3D fabs (orig) * 3.1e-30; - - cor =3D 1.0005 * cor + __copysign (eps, cor); - - if (res =3D=3D res + cor) - return res; - - a =3D fabs (x); - da =3D (x > 0) ? dx : -dx; - __dubsin (a, da, w); - eps =3D fabs (orig) * 1.1e-30; - cor =3D 1.000000001 * w[1] + __copysign (eps, w[1]); - - if (w[0] =3D=3D w[0] + cor) - return __copysign (w[0], x); - - t =3D (orig * hpinv + toint); - xn =3D t - toint; - v.x =3D t; - y =3D (orig - xn * mp1) - xn * mp2; - n =3D (v.i[LOW_HALF] + shift_quadrant) & 3; - da =3D xn * pp3; - t =3D y - da; - da =3D (y - t) - da; - y =3D xn * pp4; - a =3D t - y; - da =3D ((t - a) - y) + da; - - if (n & 2) - { - a =3D -a; - da =3D -da; - } - x =3D fabs (a); - dx =3D (a > 0) ? da : -da; - __dubsin (x, dx, w); - eps =3D fabs (orig) * 1.1e-40; - cor =3D 1.000000001 * w[1] + __copysign (eps, w[1]); - - if (w[0] =3D=3D w[0] + cor) - return __copysign (w[0], a); - - return shift_quadrant ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true= ); -} - -/* Compute sin(x + dx) where X is in the first or third quarter of the unit - circle. ORIG is the original value of X for computing error of the res= ult. - If the result is not accurate enough, the routine calls mpsin or dubsin. - SHIFT_QUADRANT rotates the unit circle by 1 to compute the cosine inste= ad of - sine. */ -static inline double -__always_inline -sloww1 (double x, double dx, double orig, bool shift_quadrant) -{ - double w[2], cor, res; - - res =3D do_sin_slow (x, dx, 3.1e-30 * fabs (orig), &cor); - - if (res =3D=3D res + cor) - return __copysign (res, x); - - dx =3D (x > 0 ? dx : -dx); - __dubsin (fabs (x), dx, w); - - double eps =3D 1.1e-30 * fabs (orig); - cor =3D 1.000000005 * w[1] + __copysign (eps, w[1]); - - if (w[0] =3D=3D w[0] + cor) - return __copysign (w[0], x); - - return shift_quadrant ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true= ); -} - -/*************************************************************************= **/ -/* Routine compute sin(x+dx) (Double-Length number) where x in second o= r */ -/* fourth quarter of unit circle.Routine receive also the original valu= e */ -/* and quarter(n=3D 1or 3)of x for computing error of result.And if result= not*/ -/* accurate enough routine calls mpsin1 or dubsin = */ -/*************************************************************************= **/ - -static inline double -__always_inline -sloww2 (double x, double dx, double orig, int n) -{ - double w[2], cor, res; - - res =3D do_cos_slow (x, dx, 3.1e-30 * fabs (orig), &cor); - - if (res =3D=3D res + cor) - return (n & 2) ? -res : res; - - dx =3D x > 0 ? dx : -dx; - __docos (fabs (x), dx, w); - - double eps =3D 1.1e-30 * fabs (orig); - cor =3D 1.000000005 * w[1] + __copysign (eps, w[1]); - - if (w[0] =3D=3D w[0] + cor) - return (n & 2) ? -w[0] : w[0]; - - return (n & 1) ? __mpsin (orig, 0, true) : __mpcos (orig, 0, true); -} - -/*************************************************************************= **/ -/* Routine compute sin(x+dx) or cos(x+dx) (Double-Length number) where x = */ -/* is small enough to use Taylor series around zero and (x+dx) = */ -/* in first or third quarter of unit circle.Routine receive also = */ -/* (right argument) the original value of x for computing error of = */ -/* result.And if result not accurate enough routine calls other routines = */ -/*************************************************************************= **/ - -static inline double -__always_inline -bsloww (double x, double dx, double orig, int n) -{ - double res, cor, w[2], a, da; - - res =3D TAYLOR_SLOW (x, dx, cor); - cor =3D 1.0005 * cor + __copysign (1.1e-24, cor); - if (res =3D=3D res + cor) - return res; - - a =3D fabs (x); - da =3D (x > 0) ? dx : -dx; - __dubsin (a, da, w); - cor =3D 1.000000001 * w[1] + __copysign (1.1e-24, w[1]); - - if (w[0] =3D=3D w[0] + cor) - return __copysign (w[0], x); - - return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true); -} - -/*************************************************************************= **/ -/* Routine compute sin(x+dx) or cos(x+dx) (Double-Length number) where x= */ -/* in first or third quarter of unit circle.Routine receive also = */ -/* (right argument) the original value of x for computing error of result= .*/ -/* And if result not accurate enough routine calls other routines = */ -/*************************************************************************= **/ - -static inline double -__always_inline -bsloww1 (double x, double dx, double orig, int n) -{ - double w[2], cor, res; - - res =3D do_sin_slow (x, dx, 1.1e-24, &cor); - if (res =3D=3D res + cor) - return (x > 0) ? res : -res; - - dx =3D (x > 0) ? dx : -dx; - __dubsin (fabs (x), dx, w); - - cor =3D 1.000000005 * w[1] + __copysign (1.1e-24, w[1]); - - if (w[0] =3D=3D w[0] + cor) - return __copysign (w[0], x); - - return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true); -} - -/*************************************************************************= **/ -/* Routine compute sin(x+dx) or cos(x+dx) (Double-Length number) where x= */ -/* in second or fourth quarter of unit circle.Routine receive also the = */ -/* original value and quarter(n=3D 1or 3)of x for computing error of resul= t. */ -/* And if result not accurate enough routine calls other routines = */ -/*************************************************************************= **/ - -static inline double -__always_inline -bsloww2 (double x, double dx, double orig, int n) -{ - double w[2], cor, res; - - res =3D do_cos_slow (x, dx, 1.1e-24, &cor); - if (res =3D=3D res + cor) - return (n & 2) ? -res : res; - - dx =3D (x > 0) ? dx : -dx; - __docos (fabs (x), dx, w); - - cor =3D 1.000000005 * w[1] + __copysign (1.1e-24, w[1]); - - if (w[0] =3D=3D w[0] + cor) - return (n & 2) ? -w[0] : w[0]; - - return (n & 1) ? __mpsin (orig, 0, true) : __mpcos (orig, 0, true); -} - -/************************************************************************/ -/* Routine compute cos(x) for 2^-27 < |x|< 0.25 by Taylor with more */ -/* precision and if still doesn't accurate enough by mpcos or docos */ -/************************************************************************/ - -static inline double -__always_inline -cslow2 (double x) -{ - double w[2], cor, res; - - res =3D do_cos_slow (x, 0, 0, &cor); - if (res =3D=3D res + cor) - return res; - - __docos (fabs (x), 0, w); - if (w[0] =3D=3D w[0] + 1.000000005 * w[1]) - return w[0]; - - return __mpcos (x, 0, false); -} - #ifndef __cos libm_alias_double (__cos, cos) #endif