From patchwork Thu Jan 7 19:23:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 41668 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 1BB4A3851C13; Thu, 7 Jan 2021 19:23:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BB4A3851C13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610047427; bh=n0LAiXade0aiw61JQNTnrZVLO2cwVVOZew7sZu+r4bQ=; 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=vi3G7y0myIiy4sNhC6VVtTSQebnNzk7i7Klr1ABlT8Ss+KSazeggrDBYq+4stny+n RMkVxZPkkzbRLSqCHWQVUSa8yhRdDcU9BE/ftNaGpmMpdd+Y3xiqLn8/X4kRyjMPxR 8Y9v2xirUE8qMutthcc1lIr2TqH9+OQtU97taoJ4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50080.outbound.protection.outlook.com [40.107.5.80]) by sourceware.org (Postfix) with ESMTPS id 3A9E03854802 for ; Thu, 7 Jan 2021 19:23:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3A9E03854802 Received: from DU2PR04CA0042.eurprd04.prod.outlook.com (2603:10a6:10:234::17) by AM0PR08MB3186.eurprd08.prod.outlook.com (2603:10a6:208:5d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 7 Jan 2021 19:23:37 +0000 Received: from DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:234:cafe::e6) by DU2PR04CA0042.outlook.office365.com (2603:10a6:10:234::17) 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:23:36 +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 DB5EUR03FT026.mail.protection.outlook.com (10.152.20.159) 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:23:36 +0000 Received: ("Tessian outbound eeda57fffe7b:v71"); Thu, 07 Jan 2021 19:23:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2a90b53ad41a3c8e X-CR-MTA-TID: 64aa7808 Received: from 74d7a15d139c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 439CCCFE-154C-4E45-B59C-9978DC53D532.1; Thu, 07 Jan 2021 19:23:30 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 74d7a15d139c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 07 Jan 2021 19:23:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nd9cHeMedgFguDm6xbvCUZmyhp3MstLOPnhYeqs5ZahCJh8HKL+UNF4CGxxkTjqsFoG5rgPtURoVSmYIIhJVY+e5kwxWY+YwJ9Kq9OhqdpqPovKVSY/wSNzsx5Ze6iphY/DhuRwEsWi00xCYPgmqE0EeKnbB+EyE/RDYKo9H7QSfRqOT8W+t47E7Shpf/sFtLAWxYZMW5fxqDGPkx/mG/AAl2LCYlV0khuQKq7myf8VIqhFAKKPfzIOakpWH657c9ekRjdx9GY3xaJnmut9BNIx8TRqVn/cGZpGBEea7qfUsCPIh3epd7pEkz8/p8JPX+H6ZNg0gsntY2Zn7HiCRHg== 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=n0LAiXade0aiw61JQNTnrZVLO2cwVVOZew7sZu+r4bQ=; b=dqecANNywWEZOs5lP+QWuA9yEq8rj40PEKVD1HqOQJ3IewZF67HGsmRcBukbwvFTNU7gmn0CjFvUbOI3mdt6mAq6SC2OxWpk2qbc8SDt4hVL09xnzrB5j6UeOW9L6hxaqaBVBJJkzk3Bcqhjy/f7oYkB1eLcy15fsUsBVJIJZUnRLOksx4OBgM4eCpLlMuH7yIKLK4KFC/8uUoJMA0SRnZnOVWYHwF01Uw/zf+fXj+LUmwI3Vi+bj0KPG+eDliKH0ahkwiaZ6Inturcm6PalvCqUM58cKIHBeGRws+722rtKqCnkv2IwIkLw+RA/lPXgGLgq31LMEsFnHIn81Q5giA== 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:23:29 +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:23:29 +0000 To: 'GNU C Library' Subject: [PATCH v2 1/5] Remove remaining slow paths from asin and acos Thread-Topic: [PATCH v2 1/5] Remove remaining slow paths from asin and acos Thread-Index: AQHW5SqUtnCkB4TkVEefYyRLEAouYg== Date: Thu, 7 Jan 2021 19:23:29 +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: dc4a3a06-d79e-4f2a-f8c2-08d8b341bb33 x-ms-traffictypediagnostic: VI1PR0801MB1760:|AM0PR08MB3186: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:4125;OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: PIHu5DxncT+uMSwGJA7duYCV5fIOi6asffQde6nrCyjw0FVgGnS0kf63xz1MjFKnY7N0c76ZISWTsrmSoB1ORaQWvx9kemKP0uJCNvOwk71ZscD7Q08MUwkEG5ZvNMKT0VRY1uyfjucVvA/3oaKYUJeUA0dgg7VPx+s3+eQUwFwcNoFqNqyzNz63uXyBlW+p90ffbTKQJVK+YQ93Zy0lONyKza8R+ZYa488w4ctrpXS1H5hdzCzrziYimfgz81jNmqtRHy+n9U0jqcPHP9bXtxzpIzUYj5wE9w4wLL/HNSZf6x99t+mgGlr7taytscrIXHNfmxjvja3um8Tdl5PXvfHk753KkOVqDQsRsNE3RRAl3uHYDGoaOJUuE4+VAgsW 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)(30864003)(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?BcHNpcpgBDi1I2ddYziv+oRJK?= =?iso-8859-1?q?fA5Tctu+Am4t56scPwCp2YG91QxdusYpz4tIzIOfhC8eNt1daCRpXjNoEo6c?= =?iso-8859-1?q?fhRH8yD+xS6TpwtVWMSuAtaozvC1iGSl7KNlQQckedRcW8wj9qd6l/e++5Sr?= =?iso-8859-1?q?P4MHT9yF+0wTlk4eOzXFmhvECjwYhsrJgl7+rFnBZ+C+dsk7xDFi59hFA0Jb?= =?iso-8859-1?q?emO2NyDHefOBOfLOhfUnBLEis+OebOn+T0jLSuzkZZly1GI2AEz/atLPE3Kl?= =?iso-8859-1?q?pKHMDfFi0gIRf7V8KPRyxagr3rtvubpw71IcsqD2XHQth/twuUNvYw+SE2Gf?= =?iso-8859-1?q?HflKW8awUirRoqxUIyqp3W6s2sZqIKRtRKnZbAJgZ6LKEa1N5lI9ml5WWHmr?= =?iso-8859-1?q?wz+vD4EBTQlnkA+5TrqT4aFWoEaWKZlUN5le1n0FyB7hw0PHxPqcup4mEfCm?= =?iso-8859-1?q?30YMgS1hb/tJyN7a3nVnbdqUICIreodUw2/W8/T5wC9GAy+mOlpIHDPbmdCA?= =?iso-8859-1?q?nL1FXsZUHZSkbRt1UqP4NlVBRmxyiYPjq7Mj4VPrCfOf/JwXbqdDI5axRYCI?= =?iso-8859-1?q?WSp6K9sURtPqViDa7m8d0Vjp9vI6rZiRW/W2mkfoPQGbSsTiveiahjoj7vir?= =?iso-8859-1?q?zufSpS0Lj3g/Vr6H28KYMxb67ZeCcTn3RN/7vtz+kspwMCqiwLtM6f0XVo09?= =?iso-8859-1?q?0y1MHFW4+CoorA/xJWRpqRh3Gh8+1CEzH1IiqdFg2rdNwAUIlmj5U9xF6L7k?= =?iso-8859-1?q?pFedzuJTo2D69XmP88omayZtzgHjUu3hHnWBmvfsIUTGUZ1vjqUPkdF2Tk5P?= =?iso-8859-1?q?h3xVv9oEE9brB2G9ffdsxWUVDkAmt9HrVwCo0xif6BAkvPzOfZuE+wEfehrq?= =?iso-8859-1?q?pRoH1w3d+hW5G2umzD6fzuKoSV8TwjBOF+64mzKPppe/6HjfuQPwOTKQShB5?= =?iso-8859-1?q?7y4o9xyHqq9LK9euJXcnfFt5/o5abocEsK6OgYF+v6xjgUtfJSA+p4x/pNY8?= =?iso-8859-1?q?LRUJt16tYaWuuYPJrU=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: DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: db19df2e-a568-4007-f1e4-08d8b341b6c6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S+SBiMzVlXiySPJshI0YO1PffWwypI20vMvOGK1nkDXAEOatW53XJmd/z4DkEXgD3lR7CAZxp5ODfCUboYvT/0WTOWBOgaf8o8zK8NBV6i0PyvKhy4zl5dwkDoQoUIuUB0EIkmAiy6ccMMixhkuJG2lF1yV13rEYEDPXViVu3R9iKlqDlrbM5TQW4MIZf9xr2lKCXXR5jD4+6tic0ZTcR2uCkCCONGtMT2r+j0s+pSnyEnEv+VMG0LKmwkiyxJUwaWR0U7EFrwNAs0/kDFFdZaDVB+Kx3wth5t8Az2DEhR6S8JyVgjVgFwbj6htABbufSjrcHk69su8CdU8/UmclX/EsLY0Clg/e3NXdOGc2W+SNpnTayuGi2tlD/u2UAX+/3JrAXRHVEToUoxeRgcIvOvCWAbDSWI3buGegP1bQAjM6bLcuTmwbWJMyiUAugZmYD7ilHLQ6GYFIEr5PjZRWGlS34BVcxxTCsqgGE60n4so= 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)(39850400004)(396003)(136003)(346002)(376002)(46966006)(47076005)(9686003)(33656002)(7696005)(82740400003)(478600001)(6916009)(34020700004)(70586007)(86362001)(336012)(70206006)(52536014)(26005)(186003)(316002)(356005)(81166007)(30864003)(82310400003)(8676002)(2906002)(55016002)(6506007)(83380400001)(5660300002)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2021 19:23:36.7846 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc4a3a06-d79e-4f2a-f8c2-08d8b341bb33 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: DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3186 X-Spam-Status: No, score=-11.8 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" This patch series removes all remaining slow paths and related code. First asin/acos, tan, atan, atan2 implementations are updated, and the final patch removes the unused mpa files, headers and probes. Passes buildmanyglibc. Remove slow paths from asin/acos. Add ULP annotations based on previous slow path checks (which may not be accurate). 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 ae5344f720055ef31b01c4af2e1228b79b821430..4473ae5df41c31e80e8fd0d74a840e8b9e718a7d 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,11 @@ # 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[]); - +/* asin with max ULP of ~0.516 based on random sampling. */ 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 +64,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.513. */ + return res; } /*---------------------0.125 <= |x| < 0.5 -----------------------------*/ else if (k < 0x3fe00000) { @@ -103,26 +78,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.524. */ + return (m>0)?res:-res; } /* else if (k < 0x3fe00000) */ /*-------------------- 0.5 <= |x| < 0.75 -----------------------------*/ else @@ -135,26 +92,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 +106,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 +122,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 +139,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 +159,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; @@ -315,11 +184,12 @@ libm_alias_finite (__ieee754_asin, __asin) /* */ /*******************************************************************/ +/* acos with max ULP of ~0.523 based on random sampling. */ 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 +206,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 +223,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 +241,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.523 based on random sampling. */ + 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 +259,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.523 based on random sampling. */ + 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 +278,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.523 based on random sampling. */ + 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 +297,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.523 based on random sampling. */ + return res; } /* else if (k < 0x3fef0000) */ /*-----------------0.96875 <= |x| < 1 ---------------------------*/ @@ -560,28 +319,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) */