From patchwork Wed Nov 8 14:50:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 24153 Received: (qmail 3590 invoked by alias); 8 Nov 2017 14:50:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 2135 invoked by uid 89); 8 Nov 2017 14:50:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR02-AM5-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH] Bypass math wrappers with -fno-math-errno Date: Wed, 8 Nov 2017 14:50:07 +0000 Message-ID: x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1PR0801MB2060; 6:KA34vxhJ6JeZ7hzKbGhIZsgN1ktCXpKBbu7EOpuiTX8id0IjZc8+68E5xqnYDEykNoZXgWGoZ3y4jwIQwuhmgIV5HcbkpYjEP4UqU12jW1AGffEbY/20yTNx1cU4183QtRSnLWMjmy342mmrJL5y4W9uwwiEoFFeiA/iMnuxyUeVu7yokOkxQ1r3K5aE49QCJbJRaPn7K+Z0wgCWxutt6Y90BFeFANI8vTjIofRPl6aykARRHDFBV0RhxIDJItYqqL013IhGuGEkqiY/wG1CKK8S7XNt9G/cPgrp40FF1NYZ73MT3lFGw13f39t46Yoq1IsAdB5XcJvXWCKG5G3Yfa2O99n0jQj1ERk737blY2M=; 5:HSqsv6AtCFcjJGwa1MuBb3DGhp3g3tJMpWp4p9j6Jifg4RpVKeXV0nU3rrORPLhy82CbSigUz3RAKxZNUWmA367aY9y7zytipqtINz3BtZIoY07rsMDJjqzVpZaS1NivcrzxSszv4C9tP9SS/WzFZfzWWnPsZaV4PsiQImgQkJQ=; 24:wUAwBXdGgizSnKgCEPgK/5hcsBT0rIR0fKH4wodEPjqBjoUWuvVMyqUxWVVzMNddPbo4u4S3U1hAFmSZWiR1HZpfPu61AcnuKMPQ/g33Lao=; 7:3ly1Bij1AbOSXyGth/XTO95WdKnRM12TrBVHZlfHrBFXc09+BJiKVK8Jo37uH1XY1lcgDBu0jm1DcYZfO6tlWfSfVETcT/fahLdD+8kcmu9+KmHQ3Wph8E8NYTsCn6G6VtTsbe504yZ117oYSWCTedMOAyp9mnzObFv1/bsklmGucI5V5FCMe+PFQM3zBUxfvRzRV6IFcxGw7/idX6Hcz0ePV7bQQ6hiurq1btX8yisRkWrNnTOewIC0QSEYfSek x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: b92298e4-f5f7-4509-f943-08d526b80111 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603249); SRVR:HE1PR0801MB2060; x-ms-traffictypediagnostic: HE1PR0801MB2060: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(180628864354917); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231021)(3002001)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123558100)(20161123564025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:HE1PR0801MB2060; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:HE1PR0801MB2060; x-forefront-prvs: 0485417665 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(376002)(346002)(189002)(54534003)(377424004)(199003)(97736004)(316002)(4326008)(7696004)(6916009)(66066001)(5660300001)(6506006)(6436002)(478600001)(189998001)(72206003)(5640700003)(53936002)(14454004)(99286004)(2900100001)(5250100002)(2501003)(3660700001)(55016002)(54356999)(305945005)(3846002)(7736002)(6116002)(3280700002)(8936002)(2906002)(33656002)(86362001)(50986999)(81156014)(81166006)(9686003)(101416001)(230783001)(102836003)(105586002)(106356001)(8676002)(2351001)(68736007)(25786009)(74316002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0801MB2060; H:HE1PR0801MB2058.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: b92298e4-f5f7-4509-f943-08d526b80111 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Nov 2017 14:50:07.5180 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2060 Several math functions have wrappers which handle errno. They are bypassed if __FINITE_MATH_ONLY__ is set. Given the wrappers impose a significant overhead, bypassing them is worthwhile (and it is best to remove them completely in the future). Since the only purpose of the wrappers is to set errno, we can bypass them if __NO_MATH_ERRNO__ is set as well. There are a few target specific functions which define finite variants of math functions and those do not set exceptions. In those cases it would be incorrect to bypass the wrapper unless __FINITE_MATH_ONLY__ is set. To support this add a define that allows targets to disable this. It's currently set for x86 and x86_64 due to defining several x87 math functions which only support finite math. OK for commit? ChangeLog: 2017-11-08 Wilco Dijkstra * math/math.h (math_errhandling): Bypass errno wrappers if __NO_MATH_ERRNO__ is defined, unless HAS_FINITE_MATH_FUNCTIONS is defined. * sysdeps/x86/fpu/bits/mathinline.h (HAS_FINITE_MATH_FUNCTIONS): Define. diff --git a/math/math.h b/math/math.h index d46c26533eff01dfbcee8f59d022febdbdb8d769..26a985728ec86fa4302455a98bf3326afc901b37 100644 --- a/math/math.h +++ b/math/math.h @@ -709,8 +709,9 @@ iszero (__T __val) #endif /* Define special entry points to use when the compiler got told to - only expect finite results. */ -#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0 + only expect finite results or errno is not used. */ +#if (defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0) \ + || (defined __NO_MATH_ERRNO__ && !defined HAS_FINITE_MATH_FUNCTIONS) /* Include bits/math-finite.h for double. */ # define _Mdouble_ double diff --git a/sysdeps/x86/fpu/bits/mathinline.h b/sysdeps/x86/fpu/bits/mathinline.h index cf29751a2781d11cd835b2e8213443b52d84f10f..973a3603240a37459baf49f341c5c294377c3bf7 100644 --- a/sysdeps/x86/fpu/bits/mathinline.h +++ b/sysdeps/x86/fpu/bits/mathinline.h @@ -20,6 +20,10 @@ # error "Never use directly; include instead." #endif +/* Some math functions have finite variants which do not support exceptions, + so we may use the finite variant only with __FINITE_MATH_ONLY__. */ +#define HAS_FINITE_MATH_FUNCTIONS 1 + #ifndef __extern_always_inline # define __MATH_INLINE __inline #else