From patchwork Mon Jan 4 12:15:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 41619 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 106693870907; Mon, 4 Jan 2021 12:15:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 106693870907 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609762554; bh=ia4uEk603r6PZa+pVUx4LxqxOFB4yqqPQVFKCQLLgHA=; 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=D2UPxn10QQBkR0r6/RJ9Anyj4Hg96KNGN8zCNhLMKnc11hIaywN75CLoIGrsL63dF ou60NNN9DFzB1MDonxTb3e2CtYmtq3H/i97v7dwl1TZwWNXRX9yEAcBkF1rmCqzlkN BkGsk97SkYAqZnQQA7wNSZ4d8foEUENBwrLhf9+I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2074.outbound.protection.outlook.com [40.107.21.74]) by sourceware.org (Postfix) with ESMTPS id 6DD7538708EE for ; Mon, 4 Jan 2021 12:15:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6DD7538708EE Received: from DB6PR07CA0077.eurprd07.prod.outlook.com (2603:10a6:6:2b::15) by PAXPR08MB6637.eurprd08.prod.outlook.com (2603:10a6:102:153::15) 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:15:47 +0000 Received: from DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2b:cafe::2b) by DB6PR07CA0077.outlook.office365.com (2603:10a6:6:2b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.4 via Frontend Transport; Mon, 4 Jan 2021 12:15:47 +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 DB5EUR03FT049.mail.protection.outlook.com (10.152.20.191) 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:15:47 +0000 Received: ("Tessian outbound 39646a0fd094:v71"); Mon, 04 Jan 2021 12:15:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bba2c8ff88d894de X-CR-MTA-TID: 64aa7808 Received: from a6b2d77ded60.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D52A622A-75D8-4E9F-A92F-D0676B4A5F82.1; Mon, 04 Jan 2021 12:15:31 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a6b2d77ded60.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 04 Jan 2021 12:15:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BekU6vc/AtAWNuuE20rKrfTol2KVlwVz0+NL70l6kxPjVi/mAf7hleN5O6RnvGqYESkWtThYJ5HVVyjZxI7wCMsQNbr8Ihjdl7hp+hIm9qkezR+ieaOI2XgIUVpxDkTEBnZwKg6o0Lqsa6w6fuK9UxPTcilxRjCG993QFJmBxeSCkIrpeS/I/f7D6p1o5cykErpgtflfiy6a9s8ZVUM6O1RcVcW1tX44LDRmzuacCJRyyTw4jkExkIIVa8vfarHA0bOV9Jzty3QInL9h1IQP43OJVAFYhs/PqOiPkWEfhf8lbdyn8Gs45L8mNV5sxMFgYr9s29Zp8DYO7A0ESpfvFw== 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=ia4uEk603r6PZa+pVUx4LxqxOFB4yqqPQVFKCQLLgHA=; b=BlPkueLsJhramb0C4yxtVNec6nBhR1nI19zIWeBmRR/RSLbg6hI5hKNS1M80peNU0pBmxkQi/DNsYFEejczs1Bsoamj9PEy5zXQkoOwOVJaRJQrjfwED4/XtL+9n9mhNZm27zoOC4Yqj+FaZiIybPIBaKdlbQx7xYMmjR8TDRLXatS8Ql/9qlWhZFASsEiKT9GSCFr6F0WkkojLFH30sZDn+Ve6Eqjw4HwGhysEkv/oPvlJsuWrz/Gqs1oHQ3lBPiaaqw9pClxG2EXQy1IU1E4d4xrAMlbUIN9z8ElAafAof3n+6ySl4lmorodXrtREsK/w6oqfE0L2SXURB37ToPQ== 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:15:30 +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:15:30 +0000 To: 'GNU C Library' Subject: [PATCH 1/5] Remove slow paths from asin Thread-Topic: [PATCH 1/5] Remove slow paths from asin Thread-Index: AQHW4pNLa+R92rzo9kyN6J89Kk60Ug== Date: Mon, 4 Jan 2021 12:15:30 +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: 49720f6a-22f1-4f98-7d54-08d8b0aa77de x-ms-traffictypediagnostic: VE1PR08MB4718:|PAXPR08MB6637: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:605;OLM:605; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: +EUK5ZjucZXsel8hXZiA+GJTkx+MAD6wS7SZBibswmRhPi0nOw8bEn1kufuUQ3m9Pwrn09sfOVu6/+JB585pbbcO0i+5qQTfGXUgOYQM+tMf0CqaFgZqiazp4woANhTbdePDHDHRv6PilxLmX2HZ9ezS69xyhwNGX0X0m3HnBaez8g81cpSxtdWY0XEW+JWrGAFKStfmo2Q9foWzhmEpsIQD0YEOWNmvUFyZWo9BMDUulo/BUALDiRg+jgSwNBGlrMG7JrvZS9CXxEUqxyYlk5a2hlT+DEkO2wTjpBOvEFoc0lzEtAjKw1caTAYIRcNFAbVHyrD5xRd2y2KyjaxWyqmcr1AFLoxf8mCHHxgQF4FYwhGck1iyYH9LAFA4lxdbMebCMf2CocowbanFcS65YQ== 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)(30864003)(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?z+ME9xXK07G2JQqo7Xs4E+/1X?= =?iso-8859-1?q?5sHlSFbsMyf+YxxCQNHGOrcICoRbSejBiOrqDnuaeNc9gFPe53uvskrnd7Pb?= =?iso-8859-1?q?bSb/+c/2r0MkmeQEQ1eWiaAbXK/wYS9HzEuBJ2/KIgfGOk3sVgfAvCV7EgRY?= =?iso-8859-1?q?XP8Syj5dGP/bWqmzLjikHIU33sNTnf1RZANCrTUxVTp31W3XZKkst22PPjZj?= =?iso-8859-1?q?Tp9aD3sO1R/uzlkp/LQqeZz5SsolIX7MXCCrA0NMXkarzNftR8Crz/IoADHv?= =?iso-8859-1?q?W0EUW4Llhcjdb08tdwG3fwC5N/Ac40+9w/eh/4XbyVxZlFkNKiGw7M4uHJfD?= =?iso-8859-1?q?Sb0rJXo5yfvl/PjD5MIeRaIVBEW/4OjsdjZPIPyWdNRsj48x2uefm2GIHflY?= =?iso-8859-1?q?56leCzUvL+GLFJKi6H4nrXYiIg+vxe1geHNtd2qbxJBV4abX9oLt/ncfpQ38?= =?iso-8859-1?q?AZbZOO+e1MoM46MgileLqmVCj8qG72R/SpjvpQSV9LlSQkXItPz6lkYHS62V?= =?iso-8859-1?q?MBEF6T+XLTp2qWZGnc3/cue9lT/PM2pzZnhYNrPIR/jjTBkkxa+GPcVE5UG2?= =?iso-8859-1?q?Rr3ear15AXtgYBaemepEz+7eerE63QaUh2Mybazg62pMIyJWwC+29Vs2/SfB?= =?iso-8859-1?q?yOmzpBbZ+15CS5rt8EnGZMRbyVkhr2Zm/qgPtfYq0b3+C4SPyIVREsb3N0de?= =?iso-8859-1?q?k8Lt4gl8GjtIzgHIakkyAyuX+RqYZwJSvWyqyEBP101G+0VOUnFgad0BXj2D?= =?iso-8859-1?q?AUFsTSB9MtHU1wGXYw8qAZb/diEHEEUeGXJRNxos2VvzmXob+TlWWv0FxrR0?= =?iso-8859-1?q?g8eZtkVXbMKawaTyGVA43/uy7X68GbAHbSLmuyioICebueHgCl2SOBckuQsk?= =?iso-8859-1?q?MQOQHzh/HQdgw2DSY4kHbCP62qX0Ioi9i2j6n0l0PBimrdrWgJ7SJywbXG/K?= =?iso-8859-1?q?2Mtky1UgUUZgA1Ni4aBiPwoFMdRAU73CNHs7Pn7Zfulvzb0poZEh0YKF/B3J?= =?iso-8859-1?q?hHFrV18wtcnnErZwFU=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: DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 37f2d6bf-7733-49ec-40c0-08d8b0aa6d95 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lMVReaVyUAQc5oS3OcDoDUNZaUi+6NQFuaHxUFytFtPZCoIIQycUUpcDBI0c8gna82fARVk5ptgbHF4u4IBcp1jcR/tmmORnlpTL+VWSHY+PphZ5xwTkJ0grmQBfDv+mukaBP5fJ1mGwrS3PyeSnm+56fcysJK6hEsphb4Mm4QsfBDWqyKxA7v0t7u5CB1dXIq4Nf2wXMIQLNuUmD1lR/+/XVJbQRgZb1RU2DYpzzGMLDT2Tt6waEg9iGsJmETH6Sjmm0HqBpsYdv4ngd3h0sOVueNCrf1TkbbVNgzOZlDNpTqOcuNBoeVLNL3jwYm80Qlx3jgR2D+4OlSlXIdrwS6N8KT1zbShNEE8DI46KpJApGW19HoDMzjTTCMT+FRZ/584tEWapUtEo26wxmiEdUCQ1HY3XthayaJSvPD0bqJ2IBIZR3ZgA5uhL5YBIRXtIcQIhgPKX5cLaljY0mfegBA== 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)(346002)(396003)(376002)(136003)(46966006)(70586007)(70206006)(336012)(6916009)(86362001)(478600001)(6506007)(186003)(26005)(83380400001)(30864003)(5660300002)(82310400003)(52536014)(47076005)(7696005)(356005)(81166007)(9686003)(82740400003)(55016002)(316002)(8936002)(2940100002)(8676002)(33656002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2021 12:15:47.4843 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49720f6a-22f1-4f98-7d54-08d8b0aa77de 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: DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6637 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SCC_5_SHORT_WORD_LINES, 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 asin - there is quite a lot of redundant slow code that can be removed while keeping ULP below 1. Add ULP annotations. Update AArch64 libm-test-ulps for asin. Passes GLIBC testsuite. diff --git a/sysdeps/aarch64/libm-test-ulps b/sysdeps/aarch64/libm-test-ulps index 22fcf8db73dc444c25e0c356b1e0036571edd112..bbadf667ee4b7a0cf80506d321553f064049c516 100644 --- a/sysdeps/aarch64/libm-test-ulps +++ b/sysdeps/aarch64/libm-test-ulps @@ -41,6 +41,7 @@ float: 2 ldouble: 2 Function: "asin": +double: 1 float: 1 ldouble: 1 @@ -55,7 +56,7 @@ float: 1 ldouble: 1 Function: "asin_upward": -double: 1 +double: 2 float: 1 ldouble: 2 diff --git a/sysdeps/ieee754/dbl-64/e_asin.c b/sysdeps/ieee754/dbl-64/e_asin.c index 8a3b26f6645b66818ad0a57fe833355a3e9961e6..c01e8a34517e4a33f126bbab5c132379b4b58a4d 100644 --- a/sysdeps/ieee754/dbl-64/e_asin.c +++ b/sysdeps/ieee754/dbl-64/e_asin.c @@ -21,8 +21,7 @@ /* */ /* FUNCTIONS: uasin */ /* uacos */ -/* FILES NEEDED: dla.h endian.h mpa.h mydefs.h usncs.h */ -/* doasin.c sincos32.c dosincos.c mpa.c */ +/* FILES NEEDED: dla.h endian.h mydefs.h usncs.h */ /* sincos.tbl asincos.tbl powtwo.tbl root.tbl */ /* */ /******************************************************************/ @@ -31,7 +30,6 @@ #include "asincos.tbl" #include "root.tbl" #include "powtwo.tbl" -#include "MathLib.h" #include "uasncs.h" #include #include @@ -43,15 +41,10 @@ # define SECTION #endif -void __doasin(double x, double dx, double w[]); -void __dubsin(double x, double dx, double v[]); -void __dubcos(double x, double dx, double v[]); -void __docos(double x, double dx, double v[]); - double SECTION __ieee754_asin(double x){ - double x1,x2,xx,s1,s2,res1,p,t,res,r,cor,cc,y,c,z,w[2]; + double x2,xx,res1,p,t,res,r,cor,cc,y,c,z; mynumber u,v; int4 k,m,n; @@ -70,27 +63,8 @@ __ieee754_asin(double x){ x2 = x*x; t = (((((f6*x2 + f5)*x2 + f4)*x2 + f3)*x2 + f2)*x2 + f1)*(x2*x); res = x+t; /* res=arcsin(x) according to Taylor series */ - cor = (x-res)+t; - if (res == res+1.025*cor) return res; - else { - x1 = x+big; - xx = x*x; - x1 -= big; - x2 = x - x1; - p = x1*x1*x1; - s1 = a1.x*p; - s2 = ((((((c7*xx + c6)*xx + c5)*xx + c4)*xx + c3)*xx + c2)*xx*xx*x + - ((a1.x+a2.x)*x2*x2+ 0.5*x1*x)*x2) + a2.x*p; - res1 = x+s1; - s2 = ((x-res1)+s1)+s2; - res = res1+s2; - cor = (res1-res)+s2; - if (res == res+1.00014*cor) return res; - else { - __doasin(x,0,w); - return w[0]; - } - } + /* Max ULP is 0.512. */ + return res; } /*---------------------0.125 <= |x| < 0.5 -----------------------------*/ else if (k < 0x3fe00000) { @@ -103,26 +77,8 @@ __ieee754_asin(double x){ +xx*asncs.x[n+6]))))+asncs.x[n+7]; t+=p; res =asncs.x[n+8] +t; - cor = (asncs.x[n+8]-res)+t; - if (res == res+1.05*cor) return (m>0)?res:-res; - else { - r=asncs.x[n+8]+xx*asncs.x[n+9]; - t=((asncs.x[n+8]-r)+xx*asncs.x[n+9])+(p+xx*asncs.x[n+10]); - res = r+t; - cor = (r-res)+t; - if (res == res+1.0005*cor) return (m>0)?res:-res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - __dubsin(res,z,w); - z=(w[0]-fabs(x))+w[1]; - if (z>1.0e-27) return (m>0)?min(res,res1):-min(res,res1); - else if (z<-1.0e-27) return (m>0)?max(res,res1):-max(res,res1); - else { - return (m>0)?res:-res; - } - } - } + /* Max ULP is 0.523. */ + return (m>0)?res:-res; } /* else if (k < 0x3fe00000) */ /*-------------------- 0.5 <= |x| < 0.75 -----------------------------*/ else @@ -135,26 +91,8 @@ __ieee754_asin(double x){ +xx*(asncs.x[n+6]+xx*asncs.x[n+7])))))+asncs.x[n+8]; t+=p; res =asncs.x[n+9] +t; - cor = (asncs.x[n+9]-res)+t; - if (res == res+1.01*cor) return (m>0)?res:-res; - else { - r=asncs.x[n+9]+xx*asncs.x[n+10]; - t=((asncs.x[n+9]-r)+xx*asncs.x[n+10])+(p+xx*asncs.x[n+11]); - res = r+t; - cor = (r-res)+t; - if (res == res+1.0005*cor) return (m>0)?res:-res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - __dubsin(res,z,w); - z=(w[0]-fabs(x))+w[1]; - if (z>1.0e-27) return (m>0)?min(res,res1):-min(res,res1); - else if (z<-1.0e-27) return (m>0)?max(res,res1):-max(res,res1); - else { - return (m>0)?res:-res; - } - } - } + /* Max ULP is 0.505. */ + return (m>0)?res:-res; } /* else if (k < 0x3fe80000) */ /*--------------------- 0.75 <= |x|< 0.921875 ----------------------*/ else @@ -167,28 +105,8 @@ __ieee754_asin(double x){ +xx*(asncs.x[n+6]+xx*(asncs.x[n+7]+xx*asncs.x[n+8]))))))+asncs.x[n+9]; t+=p; res =asncs.x[n+10] +t; - cor = (asncs.x[n+10]-res)+t; - if (res == res+1.01*cor) return (m>0)?res:-res; - else { - r=asncs.x[n+10]+xx*asncs.x[n+11]; - t=((asncs.x[n+10]-r)+xx*asncs.x[n+11])+(p+xx*asncs.x[n+12]); - res = r+t; - cor = (r-res)+t; - if (res == res+1.0008*cor) return (m>0)?res:-res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - y=hp0.x-res; - z=((hp0.x-y)-res)+(hp1.x-z); - __dubcos(y,z,w); - z=(w[0]-fabs(x))+w[1]; - if (z>1.0e-27) return (m>0)?min(res,res1):-min(res,res1); - else if (z<-1.0e-27) return (m>0)?max(res,res1):-max(res,res1); - else { - return (m>0)?res:-res; - } - } - } + /* Max ULP is 0.505. */ + return (m>0)?res:-res; } /* else if (k < 0x3fed8000) */ /*-------------------0.921875 <= |x| < 0.953125 ------------------------*/ else @@ -203,29 +121,8 @@ __ieee754_asin(double x){ xx*asncs.x[n+9])))))))+asncs.x[n+10]; t+=p; res =asncs.x[n+11] +t; - cor = (asncs.x[n+11]-res)+t; - if (res == res+1.01*cor) return (m>0)?res:-res; - else { - r=asncs.x[n+11]+xx*asncs.x[n+12]; - t=((asncs.x[n+11]-r)+xx*asncs.x[n+12])+(p+xx*asncs.x[n+13]); - res = r+t; - cor = (r-res)+t; - if (res == res+1.0007*cor) return (m>0)?res:-res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - y=(hp0.x-res)-z; - z=y+hp1.x; - y=(y-z)+hp1.x; - __dubcos(z,y,w); - z=(w[0]-fabs(x))+w[1]; - if (z>1.0e-27) return (m>0)?min(res,res1):-min(res,res1); - else if (z<-1.0e-27) return (m>0)?max(res,res1):-max(res,res1); - else { - return (m>0)?res:-res; - } - } - } + /* Max ULP is 0.505. */ + return (m>0)?res:-res; } /* else if (k < 0x3fee8000) */ /*--------------------0.953125 <= |x| < 0.96875 ------------------------*/ @@ -241,29 +138,8 @@ __ieee754_asin(double x){ xx*(asncs.x[n+9]+xx*asncs.x[n+10]))))))))+asncs.x[n+11]; t+=p; res =asncs.x[n+12] +t; - cor = (asncs.x[n+12]-res)+t; - if (res == res+1.01*cor) return (m>0)?res:-res; - else { - r=asncs.x[n+12]+xx*asncs.x[n+13]; - t=((asncs.x[n+12]-r)+xx*asncs.x[n+13])+(p+xx*asncs.x[n+14]); - res = r+t; - cor = (r-res)+t; - if (res == res+1.0007*cor) return (m>0)?res:-res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - y=(hp0.x-res)-z; - z=y+hp1.x; - y=(y-z)+hp1.x; - __dubcos(z,y,w); - z=(w[0]-fabs(x))+w[1]; - if (z>1.0e-27) return (m>0)?min(res,res1):-min(res,res1); - else if (z<-1.0e-27) return (m>0)?max(res,res1):-max(res,res1); - else { - return (m>0)?res:-res; - } - } - } + /* Max ULP is 0.505. */ + return (m>0)?res:-res; } /* else if (k < 0x3fef0000) */ /*--------------------0.96875 <= |x| < 1 --------------------------------*/ else @@ -282,16 +158,8 @@ __ieee754_asin(double x){ cor = (hp1.x - 2.0*cc)-2.0*(y+cc)*p; res1 = hp0.x - 2.0*y; res =res1 + cor; - if (res == res+1.003*((res1-res)+cor)) return (m>0)?res:-res; - else { - c=y+cc; - cc=(y-c)+cc; - __doasin(c,cc,w); - res1=hp0.x-2.0*w[0]; - cor=((hp0.x-res1)-2.0*w[0])+(hp1.x-2.0*w[1]); - res = res1+cor; - return (m>0)?res:-res; - } + /* Max ULP is 0.5015. */ + return (m>0)?res:-res; } /* else if (k < 0x3ff00000) */ /*---------------------------- |x|>=1 -------------------------------*/ else if (k==0x3ff00000 && u.i[LOW_HALF]==0) return (m>0)?hp0.x:-hp0.x; @@ -319,7 +187,7 @@ double SECTION __ieee754_acos(double x) { - double x1,x2,xx,s1,s2,res1,p,t,res,r,cor,cc,y,c,z,w[2],eps; + double x2,xx,res1,p,t,res,r,cor,cc,y,c,z; mynumber u,v; int4 k,m,n; u.x = x; @@ -336,32 +204,8 @@ __ieee754_acos(double x) r=hp0.x-x; cor=(((hp0.x-r)-x)+hp1.x)-t; res = r+cor; - cor = (r-res)+cor; - if (res == res+1.004*cor) return res; - else { - x1 = x+big; - xx = x*x; - x1 -= big; - x2 = x - x1; - p = x1*x1*x1; - s1 = a1.x*p; - s2 = ((((((c7*xx + c6)*xx + c5)*xx + c4)*xx + c3)*xx + c2)*xx*xx*x + - ((a1.x+a2.x)*x2*x2+ 0.5*x1*x)*x2) + a2.x*p; - res1 = x+s1; - s2 = ((x-res1)+s1)+s2; - r=hp0.x-res1; - cor=(((hp0.x-r)-res1)+hp1.x)-s2; - res = r+cor; - cor = (r-res)+cor; - if (res == res+1.00004*cor) return res; - else { - __doasin(x,0,w); - r=hp0.x-w[0]; - cor=((hp0.x-r)-w[0])+(hp1.x-w[1]); - res=r+cor; - return res; - } - } + /* Max ULP is 0.502. */ + return res; } /* else if (k < 0x3fc00000) */ /*---------------------- 0.125 <= |x| < 0.5 --------------------*/ else @@ -377,35 +221,16 @@ __ieee754_acos(double x) y = (m>0)?(hp0.x-asncs.x[n+8]):(hp0.x+asncs.x[n+8]); t = (m>0)?(hp1.x-t):(hp1.x+t); res = y+t; - if (res == res+1.02*((y-res)+t)) return res; - else { - r=asncs.x[n+8]+xx*asncs.x[n+9]; - t=((asncs.x[n+8]-r)+xx*asncs.x[n+9])+(p+xx*asncs.x[n+10]); - if (m>0) - {p = hp0.x-r; t = (((hp0.x-p)-r)-t)+hp1.x; } - else - {p = hp0.x+r; t = ((hp0.x-p)+r)+(hp1.x+t); } - res = p+t; - cor = (p-res)+t; - if (res == (res+1.0002*cor)) return res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - __docos(res,z,w); - z=(w[0]-x)+w[1]; - if (z>1.0e-27) return max(res,res1); - else if (z<-1.0e-27) return min(res,res1); - else return res; - } - } + /* Max ULP is 0.51. */ + return res; } /* else if (k < 0x3fe00000) */ /*--------------------------- 0.5 <= |x| < 0.75 ---------------------*/ else if (k < 0x3fe80000) { n = 1056+((k&0x000fe000)>>11)*3; - if (m>0) {xx = x - asncs.x[n]; eps=1.04; } - else {xx = -x - asncs.x[n]; eps=1.02; } + if (m>0) {xx = x - asncs.x[n]; } + else {xx = -x - asncs.x[n]; } t = asncs.x[n+1]*xx; p=xx*xx*(asncs.x[n+2]+xx*(asncs.x[n+3]+xx*(asncs.x[n+4]+ xx*(asncs.x[n+5]+xx*(asncs.x[n+6]+ @@ -414,33 +239,16 @@ __ieee754_acos(double x) y = (m>0)?(hp0.x-asncs.x[n+9]):(hp0.x+asncs.x[n+9]); t = (m>0)?(hp1.x-t):(hp1.x+t); res = y+t; - if (res == res+eps*((y-res)+t)) return res; - else { - r=asncs.x[n+9]+xx*asncs.x[n+10]; - t=((asncs.x[n+9]-r)+xx*asncs.x[n+10])+(p+xx*asncs.x[n+11]); - if (m>0) {p = hp0.x-r; t = (((hp0.x-p)-r)-t)+hp1.x; eps=1.0004; } - else {p = hp0.x+r; t = ((hp0.x-p)+r)+(hp1.x+t); eps=1.0002; } - res = p+t; - cor = (p-res)+t; - if (res == (res+eps*cor)) return res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - __docos(res,z,w); - z=(w[0]-x)+w[1]; - if (z>1.0e-27) return max(res,res1); - else if (z<-1.0e-27) return min(res,res1); - else return res; - } - } + /* Max ULP is 0.52. */ + return res; } /* else if (k < 0x3fe80000) */ /*------------------------- 0.75 <= |x| < 0.921875 -------------*/ else if (k < 0x3fed8000) { n = 992+((k&0x000fe000)>>13)*13; - if (m>0) {xx = x - asncs.x[n]; eps = 1.04; } - else {xx = -x - asncs.x[n]; eps = 1.01; } + if (m>0) {xx = x - asncs.x[n]; } + else {xx = -x - asncs.x[n]; } t = asncs.x[n+1]*xx; p=xx*xx*(asncs.x[n+2]+xx*(asncs.x[n+3]+xx*(asncs.x[n+4]+ xx*(asncs.x[n+5]+xx*(asncs.x[n+6]+xx*(asncs.x[n+7]+ @@ -449,33 +257,16 @@ __ieee754_acos(double x) y = (m>0)?(hp0.x-asncs.x[n+10]):(hp0.x+asncs.x[n+10]); t = (m>0)?(hp1.x-t):(hp1.x+t); res = y+t; - if (res == res+eps*((y-res)+t)) return res; - else { - r=asncs.x[n+10]+xx*asncs.x[n+11]; - t=((asncs.x[n+10]-r)+xx*asncs.x[n+11])+(p+xx*asncs.x[n+12]); - if (m>0) {p = hp0.x-r; t = (((hp0.x-p)-r)-t)+hp1.x; eps=1.0032; } - else {p = hp0.x+r; t = ((hp0.x-p)+r)+(hp1.x+t); eps=1.0008; } - res = p+t; - cor = (p-res)+t; - if (res == (res+eps*cor)) return res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - __docos(res,z,w); - z=(w[0]-x)+w[1]; - if (z>1.0e-27) return max(res,res1); - else if (z<-1.0e-27) return min(res,res1); - else return res; - } - } + /* Max ULP is 0.52. */ + return res; } /* else if (k < 0x3fed8000) */ /*-------------------0.921875 <= |x| < 0.953125 ------------------*/ else if (k < 0x3fee8000) { n = 884+((k&0x000fe000)>>13)*14; - if (m>0) {xx = x - asncs.x[n]; eps=1.04; } - else {xx = -x - asncs.x[n]; eps =1.005; } + if (m>0) {xx = x - asncs.x[n]; } + else {xx = -x - asncs.x[n]; } t = asncs.x[n+1]*xx; p=xx*xx*(asncs.x[n+2]+xx*(asncs.x[n+3]+xx*(asncs.x[n+4]+ xx*(asncs.x[n+5]+xx*(asncs.x[n+6] @@ -485,33 +276,16 @@ __ieee754_acos(double x) y = (m>0)?(hp0.x-asncs.x[n+11]):(hp0.x+asncs.x[n+11]); t = (m>0)?(hp1.x-t):(hp1.x+t); res = y+t; - if (res == res+eps*((y-res)+t)) return res; - else { - r=asncs.x[n+11]+xx*asncs.x[n+12]; - t=((asncs.x[n+11]-r)+xx*asncs.x[n+12])+(p+xx*asncs.x[n+13]); - if (m>0) {p = hp0.x-r; t = (((hp0.x-p)-r)-t)+hp1.x; eps=1.0030; } - else {p = hp0.x+r; t = ((hp0.x-p)+r)+(hp1.x+t); eps=1.0005; } - res = p+t; - cor = (p-res)+t; - if (res == (res+eps*cor)) return res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - __docos(res,z,w); - z=(w[0]-x)+w[1]; - if (z>1.0e-27) return max(res,res1); - else if (z<-1.0e-27) return min(res,res1); - else return res; - } - } + /* Max ULP is 0.52. */ + return res; } /* else if (k < 0x3fee8000) */ /*--------------------0.953125 <= |x| < 0.96875 ----------------*/ else if (k < 0x3fef0000) { n = 768+((k&0x000fe000)>>13)*15; - if (m>0) {xx = x - asncs.x[n]; eps=1.04; } - else {xx = -x - asncs.x[n]; eps=1.005;} + if (m>0) {xx = x - asncs.x[n]; } + else {xx = -x - asncs.x[n]; } t = asncs.x[n+1]*xx; p=xx*xx*(asncs.x[n+2]+xx*(asncs.x[n+3]+xx*(asncs.x[n+4]+ xx*(asncs.x[n+5]+xx*(asncs.x[n+6] @@ -521,25 +295,8 @@ __ieee754_acos(double x) y = (m>0)?(hp0.x-asncs.x[n+12]):(hp0.x+asncs.x[n+12]); t = (m>0)?(hp1.x-t):(hp1.x+t); res = y+t; - if (res == res+eps*((y-res)+t)) return res; - else { - r=asncs.x[n+12]+xx*asncs.x[n+13]; - t=((asncs.x[n+12]-r)+xx*asncs.x[n+13])+(p+xx*asncs.x[n+14]); - if (m>0) {p = hp0.x-r; t = (((hp0.x-p)-r)-t)+hp1.x; eps=1.0030; } - else {p = hp0.x+r; t = ((hp0.x-p)+r)+(hp1.x+t); eps=1.0005; } - res = p+t; - cor = (p-res)+t; - if (res == (res+eps*cor)) return res; - else { - res1=res+1.1*cor; - z=0.5*(res1-res); - __docos(res,z,w); - z=(w[0]-x)+w[1]; - if (z>1.0e-27) return max(res,res1); - else if (z<-1.0e-27) return min(res,res1); - else return res; - } - } + /* Max ULP is 0.52. */ + return res; } /* else if (k < 0x3fef0000) */ /*-----------------0.96875 <= |x| < 1 ---------------------------*/ @@ -560,28 +317,14 @@ __ieee754_acos(double x) cor = (hp1.x - cc)-(y+cc)*p; res1 = hp0.x - y; res =res1 + cor; - if (res == res+1.002*((res1-res)+cor)) return (res+res); - else { - c=y+cc; - cc=(y-c)+cc; - __doasin(c,cc,w); - res1=hp0.x-w[0]; - cor=((hp0.x-res1)-w[0])+(hp1.x-w[1]); - res = res1+cor; - return (res+res); - } + /* Max ULP is 0.501. */ + return (res+res); } else { cor = cc+p*(y+cc); res = y + cor; - if (res == res+1.03*((y-res)+cor)) return (res+res); - else { - c=y+cc; - cc=(y-c)+cc; - __doasin(c,cc,w); - res = w[0]; - return (res+res); - } + /* Max ULP is 0.515. */ + return (res+res); } } /* else if (k < 0x3ff00000) */