From patchwork Thu Jan 7 19:26:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 41670 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 E7EE3396EC86; Thu, 7 Jan 2021 19:26:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7EE3396EC86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610047611; bh=NKPoCO+3hIWTWCnk+IrNkXMR45zZfiUG6bK/bLjpVMg=; 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=SHVhDv6PjTtN3m81fiyyLoZI1JhSscE8Sql++U9an1MH6z/iB0pTb/Y0uygGfjLV5 d+6ksZuw6HoWPqH7KDawyrJNiL/fR+oirWaxlDea7Pol6g/bT9VzDTEBLKe3Y8DPhV qU9TjtcbMa5tUB6X2naL3BNfETkdWrZBX6XtOjjg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2083.outbound.protection.outlook.com [40.107.20.83]) by sourceware.org (Postfix) with ESMTPS id CE00B3846402 for ; Thu, 7 Jan 2021 19:26:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CE00B3846402 Received: from AM6P194CA0082.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::23) by DB7PR08MB3724.eurprd08.prod.outlook.com (2603:10a6:10:30::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.23; Thu, 7 Jan 2021 19:26:45 +0000 Received: from VE1EUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8f:cafe::1f) by AM6P194CA0082.outlook.office365.com (2603:10a6:209:8f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 7 Jan 2021 19:26:44 +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 VE1EUR03FT054.mail.protection.outlook.com (10.152.19.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 7 Jan 2021 19:26:44 +0000 Received: ("Tessian outbound 6ec21dac9dd3:v71"); Thu, 07 Jan 2021 19:26:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a1b1c28b65d716f6 X-CR-MTA-TID: 64aa7808 Received: from bdbc4ce1c7b0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3978059B-4EFB-4F62-A570-C26977931047.1; Thu, 07 Jan 2021 19:26:38 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id bdbc4ce1c7b0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 07 Jan 2021 19:26:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M4db9rJdy2diaMbKxKRdIU5CnWZ0UucBa1ZBwxmM93UaVz75+f2qI4KCnw38vAXH037Ltoy/7ilbtdsbZFvkH32tBfzpaoRsUUHLrdWOh88Hz0rz9qZgzvBy1Cv/cSM5Ic4a/4Km4ghWAbqoFTlRn/Hj4PiV3swK78sob49CBA+HO8Au6MsZucuLNHl4TZBlXwle9/vSyXmg27jglYTu9fzcedIWn7cyUs1GH+IMPIijQlFZyzrmi/tQpVcRhXxYineoq197ufpJS6sbLFyLrjNTvIj6lRw6/bLfjAGV5nowUdSapRhoJ9Wtv7q8qNtEQiVzw+wDcSBCbcwTmJ4WTQ== 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=NKPoCO+3hIWTWCnk+IrNkXMR45zZfiUG6bK/bLjpVMg=; b=nYFa55cYFc9LaJ67sx/7pKwlBmNulQSgpoMXXSlxaONFO9dY6nyMuwDdQ35RftbIUVpsDrtZ/hbdXyKfKGo+v4g5FNi0TOxkgRmx85Q+rAz+9NItyxq83Cf/DTkxEw66KODsngPoBUC9aAZsk2kk2QJgQCRD8L0qRb1hyMRaSCNEgmYmSui9XVc0AAdYuT2B/77030JUf/3WAKySSVh2SRlyV66/siEggYVnfpC9DUqnLOIxBbT1Oy9uuR8IpvJBUAgSKer2WE6GQCmd9PGdTi0uWbHOlTar7bEQdR1QCjnF9GyNh1N8HcE7o5kQycajCZgz/6+sj0z2RBuM3TIjkA== 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 VI1PR0801MB1760.eurprd08.prod.outlook.com (2603:10a6:800:51::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.21; Thu, 7 Jan 2021 19:26:37 +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.3742.006; Thu, 7 Jan 2021 19:26:37 +0000 To: 'GNU C Library' Subject: [PATCH v2 3/5] Remove slow paths from atan Thread-Topic: [PATCH v2 3/5] Remove slow paths from atan Thread-Index: AQHW5SsEizF7pJN/PUu/xPvcJtc43A== Date: Thu, 7 Jan 2021 19:26:37 +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: 8ad3f996-b8b4-4759-17ae-08d8b3422b34 x-ms-traffictypediagnostic: VI1PR0801MB1760:|DB7PR08MB3724: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:167;OLM:167; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xeN1MUBcz52TGwTTuo6PhOBiwez56LS8m8RFB5jZ6B3CAl159R6Bta7ZbF4LnKm710YqS3wNcIwC3z1HlvK5KcT4eva6hBoe4Ta0AfGU63/CzG7JOY4YeQZ3dh9XcAEeHuUHTRc1uW2CG+oflgApZvOa+jndQINtwpLhLbqf9phEpz29wKsmWwTXpaz2GHYrmqqPRyni7yVheXHTHKv9o38rtld0x7x+KrjTsoVbge2/Q8m3rfyPN7xaABryulMui6TZFAb4Fym/zAJwkc2Uf8KHaTCqTHXUi+WWaPpKn/l1aek1WezHLBYCwCFm8CxPiHxH+s46mlhLchIHJVcZcG6B5MUxx1iPs+kxKHdOzke3Ry96ZiNy4D5wDMdiZLTW 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)(396003)(136003)(346002)(376002)(366004)(39860400002)(83380400001)(6916009)(7696005)(26005)(33656002)(478600001)(55016002)(316002)(71200400001)(8936002)(5660300002)(6506007)(9686003)(76116006)(86362001)(8676002)(186003)(66446008)(2906002)(66946007)(66556008)(64756008)(66476007)(52536014); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?q?7dQN7cxDANY92L/Sl9p31DwD+?= =?iso-8859-1?q?qP7n02cZMC7ha2oHQzEUkuYhLlRFQl5VL6Y4dxG/iaYPIRC/WafoTt/0HJRC?= =?iso-8859-1?q?6XiOsnj2GUDbGpWKTmSoT7C2k4/aOG6OF+HgFO+BFgYzPz1BzMcRrRljlKKs?= =?iso-8859-1?q?k6TQQOm371oAJLUFc0CINypITnLoVgvpmeJCmwsXPMaIBzeaQAqUP7EBnvuS?= =?iso-8859-1?q?w+9CxVRU4EeSrWw8Mg8BTkav9QLiJqfw2AI/DN0m7mSecSLGFMhkcX38PSqI?= =?iso-8859-1?q?CggMN6EIHBPqW9Gdqe7sIxE+sIMoQxNjLAi2luYtJ4T/4XxMeWr07zuGG/CK?= =?iso-8859-1?q?gyIkZu6D+Bx83uNvciTf4uj1G13C/ATl1HZqvzFidLtJg/5GddH+fmOK1zAO?= =?iso-8859-1?q?m3cFEmGKsDhlGXA8xHNSY+OrOMoFez3ntSC8JazqMqDOj+5Q5ZpXFbdVVUx/?= =?iso-8859-1?q?YLVVR/yPGcdjJPuVV2lAQhLW60CG7zBiHEZ+tQlNkrmybC+u8kuyzqrOHhk+?= =?iso-8859-1?q?EzJhYl78avyOLPX50EYVlNv+og7lvCvNPLttUrbHYN4tXYuPWxy27APiLUO5?= =?iso-8859-1?q?9nPXV2M0BG9X4cuzRhcD5b3g+7H/thsNV5Fv9BYQYpM6suKksYDt7WjX3sZY?= =?iso-8859-1?q?M37NUM4TquDcMal9gcNUszbUd/NjvFtKvMj2qgusJT5XzEXhlhC3BYyHhrbt?= =?iso-8859-1?q?ceoRpSraNYY48XIn/aQLyT62KnOkNbZH+l01VR31E8al+jrTtrlo+3VuTcVP?= =?iso-8859-1?q?Q+mGdoRIegZPQuqkOizW4R3I0mXv2YfSzgFy4fXfGkOnATXYLCOFDLxKrzPP?= =?iso-8859-1?q?wNHZSC523SbhUDun4kp+1PrB/B+nb6cwqtSBVFdjeT1/21Lkm5SNdQ9Xrw52?= =?iso-8859-1?q?rRIq3Ii2cahX3jmgPjOmaPIQahjJPakQBDmZhQsBO9fk7jD47Uuxvo3DVWLK?= =?iso-8859-1?q?jvV/IzBi/LWd5NpfQbHZ+Mp9wd8DbLoECOz0AddsbWcRiYzg5pSsVqE0vK+e?= =?iso-8859-1?q?mIA95YRI+NPG0K85wA=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1760 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: VE1EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 98d1594f-d003-4457-45c8-08d8b34226c9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: thb/+FG5uLNSFpzkbZFsEBV40HXjXXq/5q0nT46H1nJ/NXyRuPJpFTYxSy3bOINXqsGNMWGXTlk9q7x9gTjAWFPt07XvZ6LdUdDmuGBKzzoCOetmCX1jr6JKYd6Hk06OLLBVuhHMuibwOP2Y5LocoUc3QBCTKejpjtYkJC+nxrO8UPZaCqHZqePYTFOXt9LBeDSVokKnW/aX1qqRe4MGs+NcOdg1RJXWLSnBUfhCj9foIhLkzQqfqJFHahXQf/Blbjw9knmzz0n/jpyaRGhY2Kj0jWqOVkBaEOC21OVPKXi9L1u6trjbC27t9R995Q7TffPXj0BVKRCDoe5x2GX/7M6ckiGUjpjRzC8t956Qj1T/Fb48PNrNl9RIjfNRf8C1/ixXIuXCvIcnt1rhJskj+DrDpzu1ZHFodgQaFQCxYoqoSEx79aAapdMbNAm+zwvZ+EdnOjzkFjdwM+/kZnJzuGFFTXw55R1RX68doJPvWIo= 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)(136003)(396003)(376002)(39850400004)(346002)(46966006)(55016002)(6916009)(70586007)(316002)(86362001)(7696005)(356005)(186003)(2906002)(9686003)(26005)(83380400001)(82740400003)(5660300002)(82310400003)(81166007)(33656002)(336012)(70206006)(8936002)(52536014)(8676002)(34020700004)(6506007)(47076005)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2021 19:26:44.5213 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ad3f996-b8b4-4759-17ae-08d8b3422b34 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: VE1EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3724 X-Spam-Status: No, score=-12.6 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 af4374019f1fce9b56b387b93a69d1330b9c8666..2b12481f0491ade9379c71ae98935ae8e67cb755 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 291b988318a67444b473044b030619d2f7851585..977183eb928f62d110e2c9e9ca6dd1f9286b1b97 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 @@ -59,17 +47,14 @@ __signArctan (double x, double y) return copysign (y, x); } - -/* An ultimate atan() routine. Given an IEEE double machine number x, */ -/* routine computes the correctly rounded (to nearest) value of atan(x). */ +/* atan with max ULP of ~0.523 based on random sampling. */ 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 8a477caa385d3f447abacf8490a8b45278d86610..fdc3e53304112eb31863a3144d6acb2f65a77a2e 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} },