From patchwork Mon Jan 4 12:19:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 41621 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D606038708D5; Mon, 4 Jan 2021 12:19:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D606038708D5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609762789; bh=cLQSPh1TUGTH/KuGMN+zBm2+vX+3pyvXvNLwoEsEPhI=; h=To:Subject:Date:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WFMR9D/NVe+xj1ymo+YDDRsqnP91gr7NKwkL4v6MU8qztlbyA4GH2mjR4LRRaE5KK 0nMzwZeDxVLavg7pKnQP/VZ7sx0JRokd/F+fXqoGhRSFDA5BtVqWCkwSu4bX3okGBb 43UitTSDxX73EgwFoE5MES7GERtXRAyipZTIKvws= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70044.outbound.protection.outlook.com [40.107.7.44]) by sourceware.org (Postfix) with ESMTPS id 9C22538708A6 for ; Mon, 4 Jan 2021 12:19:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9C22538708A6 Received: from DB6PR0501CA0021.eurprd05.prod.outlook.com (2603:10a6:4:8f::31) by AM0PR08MB5314.eurprd08.prod.outlook.com (2603:10a6:208:184::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20; Mon, 4 Jan 2021 12:19:43 +0000 Received: from DB5EUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:8f:cafe::e3) by DB6PR0501CA0021.outlook.office365.com (2603:10a6:4:8f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.20 via Frontend Transport; Mon, 4 Jan 2021 12:19:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT045.mail.protection.outlook.com (10.152.21.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.21 via Frontend Transport; Mon, 4 Jan 2021 12:19:43 +0000 Received: ("Tessian outbound 8b6e0bb22f1c:v71"); Mon, 04 Jan 2021 12:19:43 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 955584022648f6f4 X-CR-MTA-TID: 64aa7808 Received: from 3beafa7ca0d9.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 52A6D8A7-04CE-416F-9686-41A89A0903EA.1; Mon, 04 Jan 2021 12:19:38 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3beafa7ca0d9.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 04 Jan 2021 12:19:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TDsZUIwgT6R4LdApZ+niNjqXJvBbyjQszAeCYhyAyLWabzFoSvTdYyFyNLjZyjdN2lAfNUAa9vcm53KF58F60PvNtguHo86Bmep/ynpGTQZrKCMlAe3LRv4a57A8r4/2Y8JR0KT4cV9CYSe8tA2E9STRrzn8/XZVggqvJM5O5vhDCve/tF/cA5bRthEEHiL1uQ9VWaC+vvqou5eUiDb+Nbr6w3pS4qGX+Uq7dmc7yksjAhIWKvIMIWxTxr0NSNudQ5NqoGcVy2M6ZydQ35W+4ItPer0pBB/vjbZ52QJql2SG191i8uze9ytbJOOhLB/5NgZ9rdYFiVf5X7wKLpA4ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cLQSPh1TUGTH/KuGMN+zBm2+vX+3pyvXvNLwoEsEPhI=; b=l9LHrySSWvyErI57dr1ICLOd4o/rc3D7Vw0cot0BaYBtJUv1UFegJ/HtOMGg5TcnU9Edmg4o0oMHFysPefMV8zkB16ZlYpzmbXKAJLYAvtwF/iFIEOoX4DlUsggjSfFNN1XZ/AkWrVQj+nRkCPVlkrk4ydn4434nFdtznKxBs970dqzRQ1xnwxXB5tLfNO5MOpDzBYcFlZyic45jje064w8OaPFnHCyo0sdVvYHKd1DJ/F6P/MFUqdUm+NEa9CvUxkNmfrNl2TzG89E75Ybf+JBPe2uBFoy0K6B6Luv90XK92lpnepxLvsFjUwxPP0WNEU2P8WHmsxgoU+ok0tPilA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from VE1PR08MB5599.eurprd08.prod.outlook.com (2603:10a6:800:1a1::12) by VE1PR08MB4718.eurprd08.prod.outlook.com (2603:10a6:802:a5::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.22; Mon, 4 Jan 2021 12:19:35 +0000 Received: from VE1PR08MB5599.eurprd08.prod.outlook.com ([fe80::6d00:2694:e0d7:986f]) by VE1PR08MB5599.eurprd08.prod.outlook.com ([fe80::6d00:2694:e0d7:986f%5]) with mapi id 15.20.3721.024; Mon, 4 Jan 2021 12:19:35 +0000 To: 'GNU C Library' Subject: [PATCH 3/5] Remove slow paths from atan Thread-Topic: [PATCH 3/5] Remove slow paths from atan Thread-Index: AQHW4pPd+I105q7+9Uu2w+Y9xRNMUw== Date: Mon, 4 Jan 2021 12:19:35 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; x-originating-ip: [82.24.249.100] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4eabae04-5fc3-4db4-d283-08d8b0ab0482 x-ms-traffictypediagnostic: VE1PR08MB4718:|AM0PR08MB5314: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:156;OLM:156; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 7C30wxVlWZJAHb9g02fKg0IbzMz31P2X4x+bQdm0xvg2JXOqZmqyIyhZaTLEQKoUGfOVHeUxTsxt6LPF921EIkMT2Y6+XSgmtqkG0GYOL2az39Okg560D/xcKUdI/OXLF9TiW7gM+W5s6ltV3OZu5L08smPL8c01RCrQpsE3lS4UEnF95gLJq7l+jv+f0QnEGMKyOjtw7geQCQQX9yBzHaM7zmTmm+J9K8QFKLDYQg3z1qvP0Qrbfh64XNRfnJQlqPScppUQAyy1cVnYUnC7xUm1X0ecOOf9Mb8DBiKerkpO/MIYy8HHfSAhGrRzOwml5mdkbY9FjNwe2zI5pc4sEcpNvz0lmfPeplKWCXDb6CUaSKXRFLKgh5moMbB+L0u+Nq5LhcQAranqUe9RU+I9CQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR08MB5599.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(39860400002)(366004)(396003)(346002)(376002)(91956017)(66446008)(8936002)(478600001)(66476007)(66556008)(64756008)(66946007)(71200400001)(7696005)(33656002)(26005)(8676002)(186003)(55016002)(316002)(76116006)(2906002)(9686003)(86362001)(83380400001)(5660300002)(2940100002)(52536014)(6506007)(6916009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?yp6DiMqmdlf5pa6n2IMAvmI6G?= =?iso-8859-1?q?ULYMwNBfDDBj2qhYtq+51o5IDCaK8I0/LbmCZ5g/VBE5HDdv8Y6XTmNz2r/e?= =?iso-8859-1?q?Zqtpcl7vRgvCWANqZWGaIQXTrPomCIdd89AmJqHeypsCxAGLJXQXK04MCjzW?= =?iso-8859-1?q?cfRVpA4b31XY8KFMiwEXzqFv+iNbHN8UoRmd43dn04mECQUT6UY2bVIzxhMJ?= =?iso-8859-1?q?N2li+ExiGnXOgCpKkEfbM+fAO1FCv9xdQtvPShhWOvaEywGtd0yh1ZukfuUG?= =?iso-8859-1?q?7kfKn0pW9mt2fwkl1tY0INaF8vo1cDB0wP7iNd6lApZabqGITvW4aZH2vvsL?= =?iso-8859-1?q?hxqWQ55+zIW+s/FK6jF2Sfy/atPEp8uPj0gUDzHT0l7cAxospoG8pRElayf6?= =?iso-8859-1?q?5CtfVyCC06KwzXM0OcICNeRtK0/qeYd0WSz9D8vxmMu2LmAEVLvmRpvUB2wG?= =?iso-8859-1?q?jmpJSqSn0kunSY49JA8PiF1gLOmuJtSkQUVvOznZwYGA/38+QunYZ7g3OKqd?= =?iso-8859-1?q?+nfHcVaDwUVeENjERaBVhHJm9lQbhzbyPNwH1Ja5+4HGp6xGsYJnx2dtQfjK?= =?iso-8859-1?q?G7m/mknpIiVKAqgJkDAgYkh6ntrUT3HwRkoTX8PtdmaYHM1rhQcMl2hbhMco?= =?iso-8859-1?q?YiAIq4k06PQhTwkcnjSaxJ9zKb3dVpOzIz4U4k6QXPwnne1NvGQ+IJDn1nr6?= =?iso-8859-1?q?E7f0QfVGxXI8JuQ8uP1La45ZL/+CxpxiO1JvBb34RTOkVWpVUobKMoBZcnA+?= =?iso-8859-1?q?T8llyw8vbOy6ka1Jy7lOHWEq0fXGSVqys7jSR+DHDMEdtsbqzNnvK7Bitmz9?= =?iso-8859-1?q?i+Pf/1rlFxe13/YWj3wUvjtLUoj930mI02RAiFat1nB9Us/3y6aWIcvh4zm5?= =?iso-8859-1?q?c+g4rnOrQ9myAXKASjjl//WHlKfapeslX3iV5ySf59AyrNnJ+aJqRiPVL4Kp?= =?iso-8859-1?q?J6bs/cEXXaoP3Fl1K5EmZYK/tXFH3rBHjw0ownWlbhwVaaj0xESMTKdI1cbB?= =?iso-8859-1?q?5c4RQG4k3wF4DmutFo=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4718 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8bdaa13d-b6f6-4eda-619d-08d8b0aafffe X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v+8ARNosZhPTuNYUqEH/Pumeje8nDwKeF1uJthAte8KFAtmhjKvtZmL+oywPQIhXJOv8FAZQwfEbmVttF775RU9PxWlK7Qa4yS9YsdSq/QOyBkhQir0WA2hr9gFclN/+2KbLCBg4cb3oY01jimWLoS3FnhF/uQcDHzpti5w5b1DvWt+xSth70DRKNI1AtJ7UmClEBB7x/3fYlP7zP5LlcbqO9jlhfTnKH+LLWZZshhs5lH6Eic5LjHfgVGK7wooOs7KIQHVQd/jgjEqP1nrof4VKLNNi2SbfmQqpuDQsqqab1bWcOStz+rC3PM6QAray+2tFuq/d7DyqWzm3DcNo+e+2oJRCLYL4mQOr/N3Ieu+d4/P6YTQQmAlyevphF/1PGoBmt7loiJhKNP7oGXddgtNf87GTR8xMcNLftgy5bn1lJbdPPCWtAhgQo7aY4IUSEnWy5lLnW8mpkJaLSbrZvw== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(39860400002)(136003)(346002)(376002)(396003)(46966006)(8676002)(52536014)(8936002)(6506007)(33656002)(336012)(5660300002)(82310400003)(26005)(478600001)(6916009)(186003)(47076005)(82740400003)(7696005)(2906002)(316002)(70206006)(70586007)(9686003)(86362001)(55016002)(356005)(2940100002)(81166007)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2021 12:19:43.4433 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4eabae04-5fc3-4db4-d283-08d8b0ab0482 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5314 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Remove slow paths from atan. Add ULP annotations. Passes GLIBC testsuite. diff --git a/sysdeps/ieee754/dbl-64/atnat.h b/sysdeps/ieee754/dbl-64/atnat.h index bb4a2ebdc4bd9b2f2ec8ec4395b91c683eb83a8f..29d7671b86750edb810e3918d3076bab23c0f56a 100644 --- a/sysdeps/ieee754/dbl-64/atnat.h +++ b/sysdeps/ieee754/dbl-64/atnat.h @@ -29,7 +29,7 @@ #define M 4 #ifdef BIG_ENDI - static const number + static const mynumber /* polynomial I */ /**/ d3 = {{0xbfd55555, 0x55555555} }, /* -0.333... */ /**/ d5 = {{0x3fc99999, 0x999997fd} }, /* 0.199... */ @@ -79,7 +79,7 @@ #else #ifdef LITTLE_ENDI - static const number + static const mynumber /* polynomial I */ /**/ d3 = {{0x55555555, 0xbfd55555} }, /* -0.333... */ /**/ d5 = {{0x999997fd, 0x3fc99999} }, /* 0.199... */ diff --git a/sysdeps/ieee754/dbl-64/s_atan.c b/sysdeps/ieee754/dbl-64/s_atan.c index 30b0906826d005c17f9322ff7172ec06b66dc03e..fdd18920b38dda61d2ed43abfdadb0057d6d611f 100644 --- a/sysdeps/ieee754/dbl-64/s_atan.c +++ b/sysdeps/ieee754/dbl-64/s_atan.c @@ -20,25 +20,15 @@ /* MODULE_NAME: atnat.c */ /* */ /* FUNCTIONS: uatan */ -/* atanMp */ /* signArctan */ /* */ -/* */ -/* FILES NEEDED: dla.h endian.h mpa.h mydefs.h atnat.h */ -/* mpatan.c mpatan2.c mpsqrt.c */ +/* FILES NEEDED: dla.h endian.h mydefs.h atnat.h */ /* uatan.tbl */ /* */ -/* An ultimate atan() routine. Given an IEEE double machine number x */ -/* it computes the correctly rounded (to nearest) value of atan(x). */ -/* */ -/* Assumption: Machine arithmetic operations are performed in */ -/* round to nearest mode of IEEE 754 standard. */ -/* */ /************************************************************************/ #include -#include "mpa.h" -#include "MathLib.h" +#include "mydefs.h" #include "uatan.tbl" #include "atnat.h" #include @@ -47,10 +37,8 @@ #include #include #include -#include -void __mpatan (mp_no *, mp_no *, int); /* see definition in mpatan.c */ -static double atanMp (double, const int[]); +#define TWO52 0x1.0p52 /* Fix the sign of y and return */ static double @@ -60,16 +48,13 @@ __signArctan (double x, double y) } -/* An ultimate atan() routine. Given an IEEE double machine number x, */ -/* routine computes the correctly rounded (to nearest) value of atan(x). */ double __atan (double x) { - double cor, s1, ss1, s2, ss2, t1, t2, t3, t4, u, u2, u3, - v, vv, w, ww, y, yy, z, zz; + double cor, t1, t2, t3, u, + v, w, ww, y, yy, z; int i, ux, dx; - static const int pr[M] = { 6, 8, 10, 32 }; - number num; + mynumber num; num.d = x; ux = num.i[HIGH_HALF]; @@ -102,36 +87,14 @@ __atan (double x) yy = d3.d + v * yy; yy *= x * v; - if ((y = x + (yy - U1 * x)) == x + (yy + U1 * x)) - return y; - - EMULV (x, x, v, vv); /* v+vv=x^2 */ - - s1 = f17.d + v * f19.d; - s1 = f15.d + v * s1; - s1 = f13.d + v * s1; - s1 = f11.d + v * s1; - s1 *= v; - - ADD2 (f9.d, ff9.d, s1, 0, s2, ss2, t1, t2); - MUL2 (v, vv, s2, ss2, s1, ss1, t1, t2); - ADD2 (f7.d, ff7.d, s1, ss1, s2, ss2, t1, t2); - MUL2 (v, vv, s2, ss2, s1, ss1, t1, t2); - ADD2 (f5.d, ff5.d, s1, ss1, s2, ss2, t1, t2); - MUL2 (v, vv, s2, ss2, s1, ss1, t1, t2); - ADD2 (f3.d, ff3.d, s1, ss1, s2, ss2, t1, t2); - MUL2 (v, vv, s2, ss2, s1, ss1, t1, t2); - MUL2 (x, 0, s1, ss1, s2, ss2, t1, t2); - ADD2 (x, 0, s2, ss2, s1, ss1, t1, t2); - if ((y = s1 + (ss1 - U5 * s1)) == s1 + (ss1 + U5 * s1)) - return y; - - return atanMp (x, pr); + y = x + yy; + /* Max ULP is 0.511. */ + return y; } } else { /* B <= u < C */ - i = (TWO52 + TWO8 * u) - TWO52; + i = (TWO52 + 256 * u) - TWO52; i -= 16; z = u - cij[i][0].d; yy = cij[i][5].d + z * cij[i][6].d; @@ -141,44 +104,9 @@ __atan (double x) yy *= z; t1 = cij[i][1].d; - if (i < 112) - { - if (i < 48) - u2 = U21; /* u < 1/4 */ - else - u2 = U22; - } /* 1/4 <= u < 1/2 */ - else - { - if (i < 176) - u2 = U23; /* 1/2 <= u < 3/4 */ - else - u2 = U24; - } /* 3/4 <= u <= 1 */ - if ((y = t1 + (yy - u2 * t1)) == t1 + (yy + u2 * t1)) - return __signArctan (x, y); - - z = u - hij[i][0].d; - - s1 = hij[i][14].d + z * hij[i][15].d; - s1 = hij[i][13].d + z * s1; - s1 = hij[i][12].d + z * s1; - s1 = hij[i][11].d + z * s1; - s1 *= z; - - ADD2 (hij[i][9].d, hij[i][10].d, s1, 0, s2, ss2, t1, t2); - MUL2 (z, 0, s2, ss2, s1, ss1, t1, t2); - ADD2 (hij[i][7].d, hij[i][8].d, s1, ss1, s2, ss2, t1, t2); - MUL2 (z, 0, s2, ss2, s1, ss1, t1, t2); - ADD2 (hij[i][5].d, hij[i][6].d, s1, ss1, s2, ss2, t1, t2); - MUL2 (z, 0, s2, ss2, s1, ss1, t1, t2); - ADD2 (hij[i][3].d, hij[i][4].d, s1, ss1, s2, ss2, t1, t2); - MUL2 (z, 0, s2, ss2, s1, ss1, t1, t2); - ADD2 (hij[i][1].d, hij[i][2].d, s1, ss1, s2, ss2, t1, t2); - if ((y = s2 + (ss2 - U6 * s2)) == s2 + (ss2 + U6 * s2)) - return __signArctan (x, y); - - return atanMp (x, pr); + y = t1 + yy; + /* Max ULP is 0.56. */ + return __signArctan (x, y); } } else @@ -188,7 +116,7 @@ __atan (double x) w = 1 / u; EMULV (w, u, t1, t2); ww = w * ((1 - t1) - t2); - i = (TWO52 + TWO8 * w) - TWO52; + i = (TWO52 + 256 * w) - TWO52; i -= 16; z = (w - cij[i][0].d) + ww; @@ -199,37 +127,9 @@ __atan (double x) yy = HPI1 - z * yy; t1 = HPI - cij[i][1].d; - if (i < 112) - u3 = U31; /* w < 1/2 */ - else - u3 = U32; /* w >= 1/2 */ - if ((y = t1 + (yy - u3)) == t1 + (yy + u3)) - return __signArctan (x, y); - - DIV2 (1, 0, u, 0, w, ww, t1, t2, t3, t4); - t1 = w - hij[i][0].d; - EADD (t1, ww, z, zz); - - s1 = hij[i][14].d + z * hij[i][15].d; - s1 = hij[i][13].d + z * s1; - s1 = hij[i][12].d + z * s1; - s1 = hij[i][11].d + z * s1; - s1 *= z; - - ADD2 (hij[i][9].d, hij[i][10].d, s1, 0, s2, ss2, t1, t2); - MUL2 (z, zz, s2, ss2, s1, ss1, t1, t2); - ADD2 (hij[i][7].d, hij[i][8].d, s1, ss1, s2, ss2, t1, t2); - MUL2 (z, zz, s2, ss2, s1, ss1, t1, t2); - ADD2 (hij[i][5].d, hij[i][6].d, s1, ss1, s2, ss2, t1, t2); - MUL2 (z, zz, s2, ss2, s1, ss1, t1, t2); - ADD2 (hij[i][3].d, hij[i][4].d, s1, ss1, s2, ss2, t1, t2); - MUL2 (z, zz, s2, ss2, s1, ss1, t1, t2); - ADD2 (hij[i][1].d, hij[i][2].d, s1, ss1, s2, ss2, t1, t2); - SUB2 (HPI, HPI1, s2, ss2, s1, ss1, t1, t2); - if ((y = s1 + (ss1 - U7)) == s1 + (ss1 + U7)) - return __signArctan (x, y); - - return atanMp (x, pr); + y = t1 + yy; + /* Max ULP is 0.503. */ + return __signArctan (x, y); } else { @@ -249,34 +149,9 @@ __atan (double x) ww = w * ((1 - t1) - t2); ESUB (HPI, w, t3, cor); yy = ((HPI1 + cor) - ww) - yy; - if ((y = t3 + (yy - U4)) == t3 + (yy + U4)) - return __signArctan (x, y); - - DIV2 (1, 0, u, 0, w, ww, t1, t2, t3, t4); - MUL2 (w, ww, w, ww, v, vv, t1, t2); - - s1 = f17.d + v * f19.d; - s1 = f15.d + v * s1; - s1 = f13.d + v * s1; - s1 = f11.d + v * s1; - s1 *= v; - - ADD2 (f9.d, ff9.d, s1, 0, s2, ss2, t1, t2); - MUL2 (v, vv, s2, ss2, s1, ss1, t1, t2); - ADD2 (f7.d, ff7.d, s1, ss1, s2, ss2, t1, t2); - MUL2 (v, vv, s2, ss2, s1, ss1, t1, t2); - ADD2 (f5.d, ff5.d, s1, ss1, s2, ss2, t1, t2); - MUL2 (v, vv, s2, ss2, s1, ss1, t1, t2); - ADD2 (f3.d, ff3.d, s1, ss1, s2, ss2, t1, t2); - MUL2 (v, vv, s2, ss2, s1, ss1, t1, t2); - MUL2 (w, ww, s1, ss1, s2, ss2, t1, t2); - ADD2 (w, ww, s2, ss2, s1, ss1, t1, t2); - SUB2 (HPI, HPI1, s1, ss1, s2, ss2, t1, t2); - - if ((y = s2 + (ss2 - U8)) == s2 + (ss2 + U8)) - return __signArctan (x, y); - - return atanMp (x, pr); + y = t3 + yy; + /* Max ULP is 0.5003. */ + return __signArctan (x, y); } else { @@ -290,35 +165,6 @@ __atan (double x) } } - /* Final stages. Compute atan(x) by multiple precision arithmetic */ -static double -atanMp (double x, const int pr[]) -{ - mp_no mpx, mpy, mpy2, mperr, mpt1, mpy1; - double y1, y2; - int i, p; - - for (i = 0; i < M; i++) - { - p = pr[i]; - __dbl_mp (x, &mpx, p); - __mpatan (&mpx, &mpy, p); - __dbl_mp (u9[i].d, &mpt1, p); - __mul (&mpy, &mpt1, &mperr, p); - __add (&mpy, &mperr, &mpy1, p); - __sub (&mpy, &mperr, &mpy2, p); - __mp_dbl (&mpy1, &y1, p); - __mp_dbl (&mpy2, &y2, p); - if (y1 == y2) - { - LIBC_PROBE (slowatan, 3, &p, &x, &y1); - return y1; - } - } - LIBC_PROBE (slowatan_inexact, 3, &p, &x, &y1); - return y1; /*if impossible to do exact computing */ -} - #ifndef __atan libm_alias_double (__atan, atan) #endif diff --git a/sysdeps/ieee754/dbl-64/uatan.tbl b/sysdeps/ieee754/dbl-64/uatan.tbl index 9730d576d6562e7a56d6f6f59e9943ec9e8a5343..3db2804cc2833ba94ebf428ea881c4ab5e833e4c 100644 --- a/sysdeps/ieee754/dbl-64/uatan.tbl +++ b/sysdeps/ieee754/dbl-64/uatan.tbl @@ -25,7 +25,7 @@ #ifdef BIG_ENDI - static const number + static const mynumber cij[241][7] = { /* x0,cij for (1/16,1) */ /**/ {{{0X3FB04006, 0X65E0244E} }, /**/ {{0X3FB03A73, 0X7B53DD20} }, @@ -1716,7 +1716,7 @@ /**/ {{0XBF99B9A7, 0X18A3BA58} } }, }; - static const number + static const mynumber hij[241][16] = { /* x0,hij for (1/16,1) */ /**/ {{{0x3fb04000, 0x00000000} }, /**/ {{0x3fb03a6d, 0x1c06693d} }, @@ -5579,7 +5579,7 @@ #else #ifdef LITTLE_ENDI - static const number + static const mynumber cij[241][7] = { /* x0,cij for (1/16,1) */ /**/ {{{0X65E0244E, 0X3FB04006} }, /**/ {{0X7B53DD20, 0X3FB03A73} }, @@ -7270,7 +7270,7 @@ /**/ {{0X18A3BA58, 0XBF99B9A7} } }, }; - static const number + static const mynumber hij[241][16] = { /* x0,hij for (1/16,1) */ /**/ {{{0x00000000, 0x3fb04000} }, /**/ {{0x1c06693d, 0x3fb03a6d} },