From patchwork Fri Dec 31 13:24:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 49436 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 2CA8C3858025 for ; Fri, 31 Dec 2021 13:25:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CA8C3858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1640957152; bh=uNf1KQBxMHGTycajDE0kNXXjJZR313v41qccbFEoor0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Fk89FtAZOlRW5sD2OgYxCmf5OOhmDtzIqxLL4khtsQlPC0rvONM1vgbyw64PXbX6S JtMdQcZ8E2tjgMSwS4dtvO/Yx0qmtmAwxFziXnapuLEd57ncAbYbPa4ftG0LjSqR79 dBcZz4EX0B/MQWUYmmNIDNLMj32SomHJtZqUcbqA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2052.outbound.protection.outlook.com [40.107.21.52]) by sourceware.org (Postfix) with ESMTPS id 5276F3858D37 for ; Fri, 31 Dec 2021 13:25:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5276F3858D37 Received: from DB8P191CA0027.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::37) by AM0PR08MB4212.eurprd08.prod.outlook.com (2603:10a6:208:ff::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.19; Fri, 31 Dec 2021 13:25:16 +0000 Received: from DB5EUR03FT030.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:130:cafe::f8) by DB8P191CA0027.outlook.office365.com (2603:10a6:10:130::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14 via Frontend Transport; Fri, 31 Dec 2021 13:25:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;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 DB5EUR03FT030.mail.protection.outlook.com (10.152.20.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14 via Frontend Transport; Fri, 31 Dec 2021 13:25:16 +0000 Received: ("Tessian outbound c61f076cbd30:v110"); Fri, 31 Dec 2021 13:25:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 82a9bb3ef62ba9b9 X-CR-MTA-TID: 64aa7808 Received: from b2d161342d8d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EC042D61-8F04-410F-A366-2C386FF13597.1; Fri, 31 Dec 2021 13:25:09 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b2d161342d8d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 31 Dec 2021 13:25:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rr5qIf40opE+T0CgZISBQDzHvjfDnW63onQgXDkI5FTFpEJwsPDm1vuRYKHJhAwY+5jC6HS4JqLyNe9OOQb3Yg7+dS1gmOwzNFxNvtIK/Cq98a+AmUCi4Tx5ZKRf9Q1fQpeuTX43xoLG0k8JrBOAthGDdp6afzmBSBPpIVkO7yHklAW71aupymSmPS8QPyStXEaDinPYgYVmJJLHCM0QrDqaaILYwnACmHWsuWDUx+1kv4JpK8yccFwmkHJD3oRwNgCuYB+sO78qy9YDevdhQ+8mBtyNdCUJfUXb9J+Fn8G97GLwa8ggf8Kj2iSSqQhb1d7zLSTPO2XL6FAr6SGUhw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uNf1KQBxMHGTycajDE0kNXXjJZR313v41qccbFEoor0=; b=Sc9uGxiaJkTrne9Yn6fqcAJbRv7bj2XK7RdnUbSS6PRy17fORx3fpe+/GCB7QxDewd9hjdyzFDkuehPKteJ4RnvBxZjAI9W8mr5iTROcwZ/NwS93vWfpmPrp9oWlpD1n6FiNXIrUTKfO6EutwyXMzoujiB3ysf8G+fLeEjkoS1XH5pzZVnuWbmTRWLxPSqr2a9PyFEV7v0rLG/Yzj3eGLne7l9lqLbxhq0FvdyOxC5Dk3A2QXGTpZp8ayW1/3xTVC00hBNOAdCqqjQE8yWOVVNSWHyYHuzb9XPNFWvPxVMMnJnxrdl6tZ4nw+txdTeXuQWeHe9uUmo4uIif7VPvvrw== 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 Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by DU2PR08MB7272.eurprd08.prod.outlook.com (2603:10a6:10:2d7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.19; Fri, 31 Dec 2021 13:25:07 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::25f9:a7e6:422a:da43]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::25f9:a7e6:422a:da43%7]) with mapi id 15.20.4823.023; Fri, 31 Dec 2021 13:25:07 +0000 To: libc-alpha@sourceware.org Subject: [PATCH] math: Fix float conversion regressions with gcc-12 [BZ #28713] Date: Fri, 31 Dec 2021 13:24:55 +0000 Message-Id: <20211231132455.2916708-1-szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SA9PR13CA0100.namprd13.prod.outlook.com (2603:10b6:806:24::15) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 36d9d434-2654-4fd7-c7d6-08d9cc60fbbd X-MS-TrafficTypeDiagnostic: DU2PR08MB7272:EE_|DB5EUR03FT030:EE_|AM0PR08MB4212:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6790;OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Qm/gpnPNRqp95gbRLz1XN/nGd/bqSX92oyqDW1jpNXygeyjQzqujYfkJSFmnKK+C++aNfo6IUDVAkuiM2aiwE+rHxoz9brMkWWC5m/YXCsXkp/pZy7blFIk1D3Lr0RJhQWeTtexNRjV3tPoGlUGlpu9u0LG1wht9fLryY8SFDq+FoqP5Nn2+5Ca8CpGxBm3q4jKFph0vHat2IZvQ3WfkNhbWQgBj3wiYIvblpcDavYll3vHLPAP6StQhKVJhwlMtXo1zUuzjaQfl/El8DNI5gfTm4IU5QuVLW7WqA47tWDD89Jd1beS6AFKfvEZOxRWG4d0GZuBiT6m5jawHNH2it2m+MEfUwyxklMnH8IaHC2LvqfP9kmKEuz9IYjJH84MQqUyStPAABHSwzKsYPJaoI00R/donBL9PP15Qmzzqv6QWh5g8JWnK5T2xh4wVWK03dMMBMKtQJFfcfS20ctG2X08aPmzsGl/lBojsi65Kx1Q6r7nNf3UBF93i0QfDizhoLKT6bauHrzhlSBmPUX3o0izT4GofK37qSycYvo3c4mBkLEps64BVV9KJxCjkPu6iWnTJjo7CnSfEeNz70pKWg8HkN0E9CE8nP0K7MS/mPVsa63g3IJ+M0bpqzufzJMJEhnlCZyWkEzxITmMXSc3PbR3o/+8f1tJK+iduA4KlBg/t7GmTTfmKUZHcmnnPOfaJWg3/Q+tJjy/6zA9T+OpMbA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB7179.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6512007)(6486002)(66476007)(8936002)(36756003)(186003)(83380400001)(38100700002)(6916009)(6506007)(8676002)(316002)(508600001)(2906002)(66556008)(5660300002)(26005)(54906003)(44832011)(2616005)(4326008)(38350700002)(66946007)(52116002)(6666004)(86362001)(30864003)(1076003); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB7272 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 81e2951e-619b-4c8f-c3f4-08d9cc60f610 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EKMuTmdK8axXjZfsZpcxeTiikJeaIHfX3NxlTKJ5QSBG59Lr1q8xLUZPzpyL2O/+T534XiqTmOTfY8rGH7z9aoMBkv01nFf8kV+guHu3j2gp2+nXTsoEof/Z+D9uLPmpTNxt6rDPaEpk33Z93UxIdaSsZuX6apCArhBuMiooN0Po9j7wwvYSYLLc+84548MTO1fbN7/HpYzOdD0+sEKiy89IuHzTLxmqLioKmYEsh75zyro2I823T0L1nB58VHx8ZIQCuhVPAYWV3ANIuzifMY9zDdzLBgen38hvSO3AqlSJOhoynyNOqFMlu6MblwVpwGGsTFC+jh7fl4RWPGevGAhXWqLoM9GF2y4TAAActrpi/mrbM4938x96UHIPaKn1qBWboljcKwX8I3+AJV97U0YJodccOI7WeIgaoTnfxJH0VRsQvtrfTDZ8uIuITd8MAE2u37hYFpDuJ3R1zEhCiyYvvM3XtLg9hgMVvSM1v6/YEqg+8GFiaFjlDbhOX+YHyQlPlu/mmodhL9DCmomxJzYEKmz3rfoLyPzBsS9S/9iXYWcQ+SP0jlacQZn3EGUowBMH8hWlGqhiq11khTNWJm5jb0fJ6uTIq28MYEgrA4vW2zAuSrVhy0DCzCmrAB4Ly3DKOIfyKQBdDjHSPDcypRTlg8FvnP6wXeWodffDB7hGMTNwsKHG0RGtyVGh0OnnzMTyca81/YuDFpUXjB+YXw== 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)(36840700001)(46966006)(8936002)(4326008)(30864003)(316002)(36860700001)(2616005)(1076003)(36756003)(508600001)(6506007)(47076005)(356005)(70586007)(5660300002)(83380400001)(6916009)(6486002)(6512007)(6666004)(81166007)(70206006)(86362001)(8676002)(186003)(26005)(44832011)(82310400004)(107886003)(54906003)(2906002)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Dec 2021 13:25:16.2081 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 36d9d434-2654-4fd7-c7d6-08d9cc60fbbd 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: DB5EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4212 X-Spam-Status: No, score=-12.9 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Cc: Joseph Myers Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Converting double precision constants to float is now affected by the runtime dynamic rounding mode instead of being evaluated at compile time with default rounding mode (except static object initializers). This can change the computed result and cause performance regression. The known correctness issues (increased ulp errors) are already fixed, this patch fixes remaining cases of unnecessary runtime conversions. Add float M_* macros to math.h as new GNU extension API. To avoid conversions the new M_* macros are used and instead of casting double literals to float, use float literals (only required if the conversion is inexact). The patch was tested on aarch64 where the following symbols had new spurious conversion instructions that got fixed: __clog10f __gammaf_r_finite@GLIBC_2.17 __j0f_finite@GLIBC_2.17 __j1f_finite@GLIBC_2.17 __jnf_finite@GLIBC_2.17 __kernel_casinhf __lgamma_negf __log1pf __y0f_finite@GLIBC_2.17 __y1f_finite@GLIBC_2.17 cacosf cacoshf casinhf catanf catanhf clogf gammaf_positive Fixes bug 28713. Reviewed-by: Paul Zimmermann --- manual/math.texi | 7 ++++--- math/k_casinh_template.c | 2 +- math/math.h | 17 +++++++++++++++++ math/s_cacos_template.c | 2 +- math/s_catan_template.c | 2 +- math/s_catanh_template.c | 2 +- math/s_clog10_template.c | 8 ++++---- math/s_clog_template.c | 4 ++-- sysdeps/generic/math-type-macros-float.h | 5 ++--- sysdeps/ieee754/flt-32/e_gammaf_r.c | 12 ++++++------ sysdeps/ieee754/flt-32/e_j0f.c | 4 ++-- sysdeps/ieee754/flt-32/e_j1f.c | 4 ++-- sysdeps/ieee754/flt-32/e_jnf.c | 2 +- sysdeps/ieee754/flt-32/lgamma_negf.c | 8 ++++---- sysdeps/ieee754/flt-32/s_log1pf.c | 2 +- 15 files changed, 49 insertions(+), 32 deletions(-) diff --git a/manual/math.texi b/manual/math.texi index 376306cfc5..e00871c303 100644 --- a/manual/math.texi +++ b/manual/math.texi @@ -131,9 +131,10 @@ defined. The default set of features includes these constants. @xref{Feature Test Macros}. All values are of type @code{double}. As an extension, @theglibc{} -also defines these constants with type @code{long double}. The -@code{long double} macros have a lowercase @samp{l} appended to their -names: @code{M_El}, @code{M_PIl}, and so forth. These are only +also defines these constants with type @code{long double} and +@code{float}. The @code{long double} macros have a lowercase @samp{l} +while the @code{float} macros have a lowercase @samp{f} appended to +their names: @code{M_El}, @code{M_PIl}, and so forth. These are only available if @code{_GNU_SOURCE} is defined. Likewise, @theglibc{} also defines these constants with the types diff --git a/math/k_casinh_template.c b/math/k_casinh_template.c index d6ea6556b9..7bb575924b 100644 --- a/math/k_casinh_template.c +++ b/math/k_casinh_template.c @@ -56,7 +56,7 @@ M_DECL_FUNC (__kernel_casinh) (CFLOAT x, int adj) } res = M_SUF (__clog) (y); - __real__ res += (FLOAT) M_MLIT (M_LN2); + __real__ res += M_MLIT (M_LN2); } else if (rx >= M_LIT (0.5) && ix < M_EPSILON / 8) { diff --git a/math/math.h b/math/math.h index 404d24dae6..47f737b9bc 100644 --- a/math/math.h +++ b/math/math.h @@ -1158,6 +1158,23 @@ iszero (__T __val) # define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #endif +/* GNU extension to provide float constants with similar names. */ +#ifdef __USE_GNU +# define M_Ef 2.7182818284590452354f /* e */ +# define M_LOG2Ef 1.4426950408889634074f /* log_2 e */ +# define M_LOG10Ef 0.43429448190325182765f /* log_10 e */ +# define M_LN2f 0.69314718055994530942f /* log_e 2 */ +# define M_LN10f 2.30258509299404568402f /* log_e 10 */ +# define M_PIf 3.14159265358979323846f /* pi */ +# define M_PI_2f 1.57079632679489661923f /* pi/2 */ +# define M_PI_4f 0.78539816339744830962f /* pi/4 */ +# define M_1_PIf 0.31830988618379067154f /* 1/pi */ +# define M_2_PIf 0.63661977236758134308f /* 2/pi */ +# define M_2_SQRTPIf 1.12837916709551257390f /* 2/sqrt(pi) */ +# define M_SQRT2f 1.41421356237309504880f /* sqrt(2) */ +# define M_SQRT1_2f 0.70710678118654752440f /* 1/sqrt(2) */ +#endif + /* The above constants are not adequate for computation using `long double's. Therefore we provide as an extension constants with similar names as a GNU extension. Provide enough digits for the 128-bit IEEE quad. */ diff --git a/math/s_cacos_template.c b/math/s_cacos_template.c index 8c014ecf29..e0d6654c46 100644 --- a/math/s_cacos_template.c +++ b/math/s_cacos_template.c @@ -32,7 +32,7 @@ M_DECL_FUNC (__cacos) (CFLOAT x) { y = M_SUF (__casin) (x); - __real__ res = (FLOAT) M_MLIT (M_PI_2) - __real__ y; + __real__ res = M_MLIT (M_PI_2) - __real__ y; if (__real__ res == 0) __real__ res = 0; __imag__ res = -__imag__ y; diff --git a/math/s_catan_template.c b/math/s_catan_template.c index b9f8277511..b5307b3c51 100644 --- a/math/s_catan_template.c +++ b/math/s_catan_template.c @@ -106,7 +106,7 @@ M_DECL_FUNC (__catan) (CFLOAT x) if (M_FABS (__imag__ x) == 1 && M_FABS (__real__ x) < M_EPSILON * M_EPSILON) __imag__ res = (M_COPYSIGN (M_LIT (0.5), __imag__ x) - * ((FLOAT) M_MLIT (M_LN2) + * (M_MLIT (M_LN2) - M_LOG (M_FABS (__real__ x)))); else { diff --git a/math/s_catanh_template.c b/math/s_catanh_template.c index 63c14731ba..2327e48ca9 100644 --- a/math/s_catanh_template.c +++ b/math/s_catanh_template.c @@ -75,7 +75,7 @@ M_DECL_FUNC (__catanh) (CFLOAT x) if (M_FABS (__real__ x) == 1 && M_FABS (__imag__ x) < M_EPSILON * M_EPSILON) __real__ res = (M_COPYSIGN (M_LIT (0.5), __real__ x) - * ((FLOAT) M_MLIT (M_LN2) + * (M_MLIT (M_LN2) - M_LOG (M_FABS (__imag__ x)))); else { diff --git a/math/s_clog10_template.c b/math/s_clog10_template.c index 77b714a6c0..0c72db0b2e 100644 --- a/math/s_clog10_template.c +++ b/math/s_clog10_template.c @@ -72,7 +72,7 @@ M_DECL_FUNC (__clog10) (CFLOAT x) if (absx == 1 && scale == 0) { __real__ result = (M_LOG1P (absy * absy) - * ((FLOAT) M_MLIT (M_LOG10E) / 2)); + * (M_MLIT (M_LOG10E) / 2)); math_check_force_underflow_nonneg (__real__ result); } else if (absx > 1 && absx < 2 && absy < 1 && scale == 0) @@ -80,7 +80,7 @@ M_DECL_FUNC (__clog10) (CFLOAT x) FLOAT d2m1 = (absx - 1) * (absx + 1); if (absy >= M_EPSILON) d2m1 += absy * absy; - __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2); + __real__ result = M_LOG1P (d2m1) * (M_MLIT (M_LOG10E) / 2); } else if (absx < 1 && absx >= M_LIT (0.5) @@ -88,7 +88,7 @@ M_DECL_FUNC (__clog10) (CFLOAT x) && scale == 0) { FLOAT d2m1 = (absx - 1) * (absx + 1); - __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2); + __real__ result = M_LOG1P (d2m1) * (M_MLIT (M_LOG10E) / 2); } else if (absx < 1 && absx >= M_LIT (0.5) @@ -96,7 +96,7 @@ M_DECL_FUNC (__clog10) (CFLOAT x) && absx * absx + absy * absy >= M_LIT (0.5)) { FLOAT d2m1 = M_SUF (__x2y2m1) (absx, absy); - __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2); + __real__ result = M_LOG1P (d2m1) * (M_MLIT (M_LOG10E) / 2); } else { diff --git a/math/s_clog_template.c b/math/s_clog_template.c index 0f6360cdc8..72414a812b 100644 --- a/math/s_clog_template.c +++ b/math/s_clog_template.c @@ -32,7 +32,7 @@ M_DECL_FUNC (__clog) (CFLOAT x) if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ - __imag__ result = signbit (__real__ x) ? (FLOAT) M_MLIT (M_PI) : 0; + __imag__ result = signbit (__real__ x) ? M_MLIT (M_PI) : 0; __imag__ result = M_COPYSIGN (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ __real__ result = -1 / M_FABS (__real__ x); @@ -94,7 +94,7 @@ M_DECL_FUNC (__clog) (CFLOAT x) else { FLOAT d = M_HYPOT (absx, absy); - __real__ result = M_LOG (d) - scale * (FLOAT) M_MLIT (M_LN2); + __real__ result = M_LOG (d) - scale * M_MLIT (M_LN2); } __imag__ result = M_ATAN2 (__imag__ x, __real__ x); diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h index 5ba7615500..cf7ba5d6a3 100644 --- a/sysdeps/generic/math-type-macros-float.h +++ b/sysdeps/generic/math-type-macros-float.h @@ -27,9 +27,8 @@ #define M_STRTO_NAN __strtof_nan #define M_USE_BUILTIN(c) USE_ ##c ##F_BUILTIN -/* Standard/GNU macro literals do not exist for the float type. Use - the double macro constants. */ -#define M_MLIT(c) c +/* GNU extension float constant macros. */ +#define M_MLIT(c) c ## f #include #include diff --git a/sysdeps/ieee754/flt-32/e_gammaf_r.c b/sysdeps/ieee754/flt-32/e_gammaf_r.c index 974ed67c96..3fcfc581b3 100644 --- a/sysdeps/ieee754/flt-32/e_gammaf_r.c +++ b/sysdeps/ieee754/flt-32/e_gammaf_r.c @@ -85,7 +85,7 @@ gammaf_positive (float x, int *exp2_adj) float x_adj_frac = x_adj - x_adj_int; int x_adj_log2; float x_adj_mant = __frexpf (x_adj, &x_adj_log2); - if (x_adj_mant < (float) M_SQRT1_2) + if (x_adj_mant < M_SQRT1_2f) { x_adj_log2--; x_adj_mant *= 2.0f; @@ -94,7 +94,7 @@ gammaf_positive (float x, int *exp2_adj) float ret = (__ieee754_powf (x_adj_mant, x_adj) * __ieee754_exp2f (x_adj_log2 * x_adj_frac) * __ieee754_expf (-x_adj) - * sqrtf (2 * (float) M_PI / x_adj) + * sqrtf (2 * M_PIf / x_adj) / prod); exp_adj += x_eps * __ieee754_logf (x_adj); float bsum = gamma_coeff[NCOEFF - 1]; @@ -176,11 +176,11 @@ __ieee754_gammaf_r (float x, int *signgamp) if (frac > 0.5f) frac = 1.0f - frac; float sinpix = (frac <= 0.25f - ? __sinf ((float) M_PI * frac) - : __cosf ((float) M_PI * (0.5f - frac))); + ? __sinf (M_PIf * frac) + : __cosf (M_PIf * (0.5f - frac))); int exp2_adj; - float tret = (float) M_PI / (-x * sinpix - * gammaf_positive (-x, &exp2_adj)); + float tret = M_PIf / (-x * sinpix + * gammaf_positive (-x, &exp2_adj)); ret = __scalbnf (tret, -exp2_adj); math_check_force_underflow_nonneg (ret); } diff --git a/sysdeps/ieee754/flt-32/e_j0f.c b/sysdeps/ieee754/flt-32/e_j0f.c index 0453a30109..9ae91a9dcc 100644 --- a/sysdeps/ieee754/flt-32/e_j0f.c +++ b/sysdeps/ieee754/flt-32/e_j0f.c @@ -233,7 +233,7 @@ j0f_near_root (float x, float z) float index_f; int index; - index_f = roundf ((x - FIRST_ZERO_J0) / (float) M_PI); + index_f = roundf ((x - FIRST_ZERO_J0) / M_PIf); /* j0f_asympt fails to give an error <= 9 ulps for x=0x1.324e92p+7 (index 48) thus we can't reduce SMALL_SIZE below 49. */ if (index_f >= SMALL_SIZE) @@ -514,7 +514,7 @@ y0f_near_root (float x, float z) float index_f; int index; - index_f = roundf ((x - FIRST_ZERO_Y0) / (float) M_PI); + index_f = roundf ((x - FIRST_ZERO_Y0) / M_PIf); if (index_f >= SMALL_SIZE) return y0f_asympt (x); index = (int) index_f; diff --git a/sysdeps/ieee754/flt-32/e_j1f.c b/sysdeps/ieee754/flt-32/e_j1f.c index 052c661db9..ade10402fd 100644 --- a/sysdeps/ieee754/flt-32/e_j1f.c +++ b/sysdeps/ieee754/flt-32/e_j1f.c @@ -243,7 +243,7 @@ j1f_near_root (float x, float z) x = -x; sign = -1.0f; } - index_f = roundf ((x - FIRST_ZERO_J1) / (float) M_PI); + index_f = roundf ((x - FIRST_ZERO_J1) / M_PIf); if (index_f >= SMALL_SIZE) return sign * j1f_asympt (x); index = (int) index_f; @@ -525,7 +525,7 @@ y1f_near_root (float x, float z) float index_f; int index; - index_f = roundf ((x - FIRST_ZERO_Y1) / (float) M_PI); + index_f = roundf ((x - FIRST_ZERO_Y1) / M_PIf); if (index_f >= SMALL_SIZE) return y1f_asympt (x); index = (int) index_f; diff --git a/sysdeps/ieee754/flt-32/e_jnf.c b/sysdeps/ieee754/flt-32/e_jnf.c index 80b684dd97..ff0a9d7c63 100644 --- a/sysdeps/ieee754/flt-32/e_jnf.c +++ b/sysdeps/ieee754/flt-32/e_jnf.c @@ -134,7 +134,7 @@ __ieee754_jnf(int n, float x) tmp = n; v = two/x; tmp = tmp*__ieee754_logf(fabsf(v*tmp)); - if(tmp<(float)8.8721679688e+01) { + if(tmp<8.8721679688e+01f) { for(i=n-1,di=(float)(i+i);i>0;i--){ temp = b; b *= di; diff --git a/sysdeps/ieee754/flt-32/lgamma_negf.c b/sysdeps/ieee754/flt-32/lgamma_negf.c index ba6ada8f7e..d1128cc91c 100644 --- a/sysdeps/ieee754/flt-32/lgamma_negf.c +++ b/sysdeps/ieee754/flt-32/lgamma_negf.c @@ -165,9 +165,9 @@ static float lg_sinpi (float x) { if (x <= 0.25f) - return __sinf ((float) M_PI * x); + return __sinf (M_PIf * x); else - return __cosf ((float) M_PI * (0.5f - x)); + return __cosf (M_PIf * (0.5f - x)); } /* Compute cos (pi * X) for -0.25 <= X <= 0.5. */ @@ -176,9 +176,9 @@ static float lg_cospi (float x) { if (x <= 0.25f) - return __cosf ((float) M_PI * x); + return __cosf (M_PIf * x); else - return __sinf ((float) M_PI * (0.5f - x)); + return __sinf (M_PIf * (0.5f - x)); } /* Compute cot (pi * X) for -0.25 <= X <= 0.5. */ diff --git a/sysdeps/ieee754/flt-32/s_log1pf.c b/sysdeps/ieee754/flt-32/s_log1pf.c index 6630f5a78e..555f0f82c8 100644 --- a/sysdeps/ieee754/flt-32/s_log1pf.c +++ b/sysdeps/ieee754/flt-32/s_log1pf.c @@ -92,7 +92,7 @@ __log1pf(float x) if(k==0) return zero; else {c += k*ln2_lo; return k*ln2_hi+c;} } - R = hfsq*((float)1.0-(float)0.66666666666666666*f); + R = hfsq*(1.0f-0.66666666666666666f*f); if(k==0) return f-R; else return k*ln2_hi-((R-(k*ln2_lo+c))-f); }