From patchwork Tue Sep 26 13:22:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 23155 Received: (qmail 60061 invoked by alias); 26 Sep 2017 13:22:17 -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 60048 invoked by uid 89); 26 Sep 2017 13:22:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:4052 X-HELO: EUR03-VE1-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH 1/3] Cleanup __ieee754_sqrt(f/l) Date: Tue, 26 Sep 2017 13:22:10 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0801MB2053; 6:Q0uKedh6+sQ+4fPWAgSGdAn7nf5QiOv59EfcOSym4lmTxS7WRfsSPCyuPeYqm1zZeepWfwirUi0gaQiaO0tEJz5Jkw7E5R50CTtW6LFDVq7IYXoVCgO4Bi5ldLjYAJFbOtwYECJ4Mt5HZgyni5MtTc+qScBBEVbVjPSdIAL8XNKtJsLIe8/jMEG77s6Lzu7dw+rbEJ7Qx14NJOQwCCa11Z6t+f+HLHOkVymzB/zWvDYyEa0iCZXPC7vWJ12qnTYAACcKcpTMZezHREbBX+ScNWRohg8elmJDD2/Hkj2uz4UFrZ6DWQ5YKK+ThLITs6OYONrPHuTznZiw3DLnIJvwpA==; 5:/ToSJKz7HB28LvoWG1qsKhROfaqg0mVJZLcfDRIIU93FyCJjLXBQOO1XbUEsy4VHTwoMT9IPB4dIxaADQLjRlXmFVJKiYu9IRSrw4q7p14ixqW/zsLqybbqZ4HeBmyDgOhdM7kvSktxl4gmNoigH7Q==; 24:fJTRq6NrNnqKxE5fBcZxtvsfa6uV+UmyeOU7GVddhG3zVtzZw1D/Jk9ja3ElMAn2TEGnwakdcORIlg9YGlGcHzC0reguW4X1D3EFLeCK4WU=; 7:dzztTpvgSxgQtQnDfTcmLK81/xt2H+2rYuWRjPurhEvWmZ4iJuxXVUCqpq38GOvLRcRtZIMqu6FRPU/OY/L9vGuscpAJ3z9sf1Cq5rtjK+oLbm/M42qtSkU1P9xsEiXYk3b+jpTWXq5gGeYKK08g8Rv6lu4i5lOgNYVqED0JEPe4gaZNVwt4+XH6ENZs3Fx3kbA2XjEE/Kj0wURJTfbHmukx3zWBYVma500A+zUHcLk= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: f69ba911-eb98-4587-b3ee-08d504e197c8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:DB6PR0801MB2053; x-ms-traffictypediagnostic: DB6PR0801MB2053: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(250305191791016)(180628864354917)(22074186197030); 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)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123558100)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB6PR0801MB2053; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB6PR0801MB2053; x-forefront-prvs: 0442E569BC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(39860400002)(377424004)(54534003)(199003)(189002)(6116002)(55016002)(2501003)(316002)(575784001)(72206003)(99286003)(74316002)(50986999)(54356999)(68736007)(25786009)(8936002)(2900100001)(5250100002)(81166006)(8676002)(305945005)(97736004)(106356001)(7736002)(101416001)(81156014)(33656002)(3660700001)(2351001)(66066001)(478600001)(86362001)(105586002)(2906002)(3280700002)(6436002)(6506006)(5640700003)(189998001)(9686003)(53936002)(14454004)(6916009)(5660300001)(7696004)(4326008)(102836003)(3846002)(6306002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB2053; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2017 13:22:10.2208 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2053 This patch series cleans up the many uses of __ieee754_sqrt(f/l) in GLIBC. The goal is to enable GCC to do the inlining, and if this fails call the __ieee754_sqrt function. This is done by internally declaring sqrt with asm redirects. The compat symbols and sqrt wrappers need to disable the redirect. This means targets are no longer forced to add a special inline for sqrt. All math functions (but not math tests) are built with -fno-math-errno which means GCC will inline sqrt as a single instruction. ChangeLog: 2017-09-25 Wilco Dijkstra * include/math.h (sqrt): Declare with asm redirect. (sqrtf): Likewise. (sqrtl): Likewise. * math/Makefile: Add -fno-math-errno, but build tests with -fmath-errno. * math/w_sqrt_compat.c: Define NO_SQRT_REDIRECT. * math/w_sqrt_template.c: Likewise. * math/w_sqrtf_compat.c: Likewise. * math/w_sqrtl_compat.c: Likewise. diff --git a/include/math.h b/include/math.h index fe3ed1378d19faf572b48347b41501d9ec0925b5..e176b090caa9f07c226aff0f9c6c5bf34740f2ec 100644 --- a/include/math.h +++ b/include/math.h @@ -55,5 +55,15 @@ libm_hidden_proto (__expf128) libm_hidden_proto (__expm1f128) # endif +# ifndef NO_SQRT_REDIRECT +/* Declare sqrt for use within GLIBC. Sqrt will typically inline into a + single instruction. Use an asm to avoid use of PLTs if it doesn't. */ +float sqrtf (float) asm ("__ieee754_sqrtf"); +double sqrt (double) asm ("__ieee754_sqrt"); +# ifndef __NO_LONG_DOUBLE_MATH +long double sqrtl (long double) asm ("__ieee754_sqrtl"); +# endif +# endif + #endif #endif diff --git a/math/Makefile b/math/Makefile index 04586156f8050222b2aedcebc30dab7153a1b6b1..ad65dd7677dd3c6a91fb2f393e5ca43769f3ddec 100644 --- a/math/Makefile +++ b/math/Makefile @@ -500,6 +500,12 @@ endef object-suffixes-left := $(types) include $(o-iterator) +define o-iterator-doit +$(objpfx)$(o).o: CFLAGS += -fmath-errno +endef +object-suffixes-left := $(tests) $(tests-internal) +include $(o-iterator) + # Run the math programs to automatically generate ULPs files. .PHONY: regen-ulps @@ -547,6 +553,8 @@ include $(o-iterator) # only the fdlibm code. math-CPPFLAGS += -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES +config-extra-cflags += -fno-math-errno + ifneq ($(long-double-fcts),yes) # The `double' and `long double' types are the same on this machine. # We won't compile the `long double' code at all. Tell the `double' code diff --git a/math/w_sqrt_compat.c b/math/w_sqrt_compat.c index 3280d2fbb86af2aeaf6e686fd38579b209c901aa..fe068af9597ffb0f15b32cd454b4c34ba8bc060e 100644 --- a/math/w_sqrt_compat.c +++ b/math/w_sqrt_compat.c @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see . */ +#define NO_SQRT_REDIRECT #include #include #include diff --git a/math/w_sqrt_template.c b/math/w_sqrt_template.c index 5fae302382d10e9b05df2665c9cb05126cd62f02..235c263e60c85422e41bca7c817148b66030438f 100644 --- a/math/w_sqrt_template.c +++ b/math/w_sqrt_template.c @@ -21,6 +21,7 @@ for each floating-point type. */ #if __USE_WRAPPER_TEMPLATE +#define NO_SQRT_REDIRECT # include # include # include diff --git a/math/w_sqrtf_compat.c b/math/w_sqrtf_compat.c index 6c8c7e3857c7dacf52de6b575a2386095688b5dc..880be0936d9a20f9aa75cf2d66000f0c621f090f 100644 --- a/math/w_sqrtf_compat.c +++ b/math/w_sqrtf_compat.c @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see . */ +#define NO_SQRT_REDIRECT #include #include #include diff --git a/math/w_sqrtl_compat.c b/math/w_sqrtl_compat.c index 0590f6d155fee27d41bfd42c1dbdf19c381ba1c8..bff77fd31bf2c62394e0d54e6b2e7bc9296226d6 100644 --- a/math/w_sqrtl_compat.c +++ b/math/w_sqrtl_compat.c @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see . */ +#define NO_SQRT_REDIRECT #include #include #include