From patchwork Thu Jan 2 14:34:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 854651 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7803276wrq; Thu, 2 Jan 2025 06:35:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUi5ZtH6onIIkxy8Itxrq2MAS5eJMnzxn6FaPqxLolIAZ7QrGtG4OOWoflV5lTwiBzb4+tuwA==@linaro.org X-Google-Smtp-Source: AGHT+IGKMyejQsNztDS0e81H6rYdzeqcs3K2oPmIjsdvWspWOvbE7+rnwhV9IGnYodqZ1fslAoiC X-Received: by 2002:a05:620a:3193:b0:7b6:cdd4:bdd8 with SMTP id af79cd13be357-7b9ba73a8b5mr6412108685a.16.1735828508694; Thu, 02 Jan 2025 06:35:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1735828508; cv=pass; d=google.com; s=arc-20240605; b=RE9XHoRbm9DmgLArkLy7SccjiFaNi4uH3UPVH2QtCnfyPUVqs+9gsJTQ+eC2LNuWHu Sj4IsjfzIJQtLkyhvGHAvIJhTkYHPUlcsUrAomsZMvvuqIvEqVOUI42IHFsF+7PmKfhq H3B1otdifD0CQ/WoxVJSEOwj4uxB3rqP6S8j6cRG9OweIEUVeBaC2T+dLL7o5in40/Xf WWtrRDXN7XELWReK0ucOTFXLU7QLLxoIY7t6nzZOZo5X2RnPuOZtIeauwqlCMdj57XQz 4icFUFdnjophG1bQKq2qFx1eOfaBE3AjehPNwZ44qExrFKyIqn32MD1FrE9+l3nzOVk1 vfOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter:arc-filter:dmarc-filter:delivered-to:dkim-filter; bh=pvnwJeOC9QMlUpNHLDGccF4iEUD6lcnNrxpcz9fQUK8=; fh=sQ6VrpwIgpWTwGFMYMpywmdT6hbxYROjBvrVuzEpKr4=; b=JEmrmBn5Ia8/XqatKEnsXKU2u1SkwjL9n5MjTUDjKVk8cFqXC87JZaG2YFyGzim1Xc cQ6jKlztqBqZf0Ii3tboEAU+CSUl0TQDjPTluu4exw4oUMCdfOaYYb1CX9FFEuOTzL8u lgB2ENBxURPiloATXRNrIJ00i80TUeWRSSEHRYINYU85E7ggqj9WxbX+bvpaFusuYCdG BsNZdDjcHSFvu4RFOPkoGA/alONfUMG0FfddsjRm1VZDjRTI5IF0sgjlbih/AJ7Xpf8h l457AnaqKhzri4UlGQsNg/VC51/C+n0zoWvyijUk3+O9jzyo8KJC3sYiTVdYTEikC+HV 98VA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fsJf4+B8; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac2ab75asi2586757285a.26.2025.01.02.06.35.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2025 06:35:08 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fsJf4+B8; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 463A33858D38 for ; Thu, 2 Jan 2025 14:35:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 463A33858D38 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=fsJf4+B8 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by sourceware.org (Postfix) with ESMTPS id E08B53858D1E for ; Thu, 2 Jan 2025 14:34:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E08B53858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E08B53858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1033 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735828491; cv=none; b=luQ8hETJTUF6NFLY9DPL3uavCYElvyFKS3SgHbYKgMil7v0Dw7vwe0FughShXMg06y8zU7CCNd7J4SoXAcTIreQa2enuHDIXjEjp5JshLCuXaPJC+agpplpsDUlQfqzSa+ZzI9U/r8ZSD0OifgvshYTLX6lSTRHNOUGTMTipKz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735828491; c=relaxed/simple; bh=RagKiPW+MbT3CQNPlRU+LYB4Sf8CKDzRu2/46fUQOiI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qDl/LOibH0rYZW4sUcCfTrkGDOPxcoV9zotSJdeX0Po+dfAVUlGxPOAXn+HcqrI90g+2gyn6vSke2y4Hqh2+mB+2Qr2ElxuU+rOk1w9Y+XEMqfsjQv7cugnoHAki9jnkbmntBqV9yDpVQJpLYs0goKEw+L+WjB2AQJw7lAD5k0A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E08B53858D1E Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2f441791e40so12750166a91.3 for ; Thu, 02 Jan 2025 06:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735828489; x=1736433289; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pvnwJeOC9QMlUpNHLDGccF4iEUD6lcnNrxpcz9fQUK8=; b=fsJf4+B8M0FlJdTkYHGAhJV0NLD+IUMa2Zvl5Hz+x+4/C7pzwDjINQPdp+EZxD4HDa 7uH+M7ILTUzhGU4Kxe69fvuvEHikIEvWk+g4x8VLBqz6fisg2OC6wU54vOZyQhZKepgh 1W2N+8MC6783qEQimJTD/dTA8Vi4dyOlpCxLrsfhaL5Z0/07+HRSklsViAjSt2h+MUwb 5IZAbCBJALh62ncpJBLS276zxr/knJpKmGzXQwud9OK9NceYXIrQ0EbT3oeMozmcxEvO oRL9aHzCeypC1SgcnWtBorV8GQgv3UdOSQz35RyOyHpPaOcJeOg4L7vh3AiuSMqlrTDB KR4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735828489; x=1736433289; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pvnwJeOC9QMlUpNHLDGccF4iEUD6lcnNrxpcz9fQUK8=; b=QjIRXJBjWFMhR7XdIO41uqk8RbMOWRrnzjQrJWinS8BfGnYIkt2BCoKYdhxyRI/nWs W988tuer8LcKhTUEMsTIdub74xaIxzTLoEAcrgJFI0ao3QY2i4E7cydPXbL0Xsp84xqI uzHtpkmyZtU3+eCy+QwKxXidWgW6uXEDhJRi1SRAitTo8o/6Lh6a6ZrGq4y8q3714gWg w1hFfUq+4xQwy6jUkHFQ05sI5M52zhvrON/g6sMb6Avr+fDNQSvoEa1jSfJybbNFVyTT RYDO3vZCSFCctaysgVOt/IuWmw+ZNcCKT7SEZaRGIM0kcf3pSMzfbcQhjzNUVQGVwRLj vBqA== X-Gm-Message-State: AOJu0YxadZwBoEGVxDSq1wQLu1hsDD8O3XMyHDjpfcjkFZQkIzKceJK1 +gGiYiWXub1ovxz6XpPqE2/AfHHLB8sKt5Yf+L1XcEG+sFPHhMN3yg6awS8kCRj/tEagH8iSwwe l X-Gm-Gg: ASbGncuIclIMhplls+9fwv2/mrLeOYeYF/jP05bfGboNWE9IrMXbtIbTT6bb/YxF2b1 Qv1Ap4fP759szZZrqXLbh9/aDl20qR7Alm8l4Pvn0TZW/JeFVUx9SqifA80ZRabJF+FU2ca5GFj V5nBuOe7+YEJwRQmggRWHX/W2nvTpkvFbR2AwP6jmINLvzS3D7GgUcpAeRaokj59A7uyjGHnnb0 6lqf8cCH3s4cMELQ+bVGy8C5sMWF4i2tmZ1W5EU7bpi4JwXsfk1YBx9dZTSrBaEEic5AkrCVMVG daXbtBYbJOKz4+b5RVKhweXUjMtM X-Received: by 2002:a17:90b:3ccc:b0:2ef:3192:d280 with SMTP id 98e67ed59e1d1-2f452dfaed8mr71420768a91.5.1735828489299; Thu, 02 Jan 2025 06:34:49 -0800 (PST) Received: from ubuntu-vm.. (201-92-186-201.dsl.telesp.net.br. [201.92.186.201]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f4477ef3d9sm26395843a91.26.2025.01.02.06.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2025 06:34:48 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann , Florian Weimer Subject: [PATCH] math: Fix acosf when building with gcc <= 11 Date: Thu, 2 Jan 2025 11:34:21 -0300 Message-ID: <20250102143444.3574078-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org GCC <= 11 wrongly assumes the rounding is to nearest and performs a constant folding where it should evaluate since the result is not exact [1]. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57245 --- sysdeps/aarch64/libm-test-ulps | 2 -- sysdeps/i386/fpu/libm-test-ulps | 2 -- sysdeps/i386/i686/fpu/multiarch/libm-test-ulps | 2 -- sysdeps/ieee754/flt-32/e_acosf.c | 10 +++++++--- sysdeps/powerpc/fpu/libm-test-ulps | 2 -- sysdeps/x86_64/fpu/libm-test-ulps | 2 -- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/sysdeps/aarch64/libm-test-ulps b/sysdeps/aarch64/libm-test-ulps index f1ab172f27..190685f893 100644 --- a/sysdeps/aarch64/libm-test-ulps +++ b/sysdeps/aarch64/libm-test-ulps @@ -11,7 +11,6 @@ float: 1 Function: "acos_downward": double: 1 -float: 1 ldouble: 1 Function: "acos_sve": @@ -20,7 +19,6 @@ float: 1 Function: "acos_towardzero": double: 1 -float: 1 ldouble: 1 Function: "acos_upward": diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index 27f0f71b0a..423061e12e 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -7,12 +7,10 @@ float128: 1 ldouble: 2 Function: "acos_downward": -float: 1 float128: 1 ldouble: 2 Function: "acos_towardzero": -float: 1 float128: 1 ldouble: 2 diff --git a/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps b/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps index 66733c2d1d..466e68dae0 100644 --- a/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps +++ b/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps @@ -7,12 +7,10 @@ float128: 1 ldouble: 2 Function: "acos_downward": -float: 1 float128: 1 ldouble: 2 Function: "acos_towardzero": -float: 1 float128: 1 ldouble: 2 diff --git a/sysdeps/ieee754/flt-32/e_acosf.c b/sysdeps/ieee754/flt-32/e_acosf.c index cba01221dc..a5a4de4fc2 100644 --- a/sysdeps/ieee754/flt-32/e_acosf.c +++ b/sysdeps/ieee754/flt-32/e_acosf.c @@ -3,7 +3,7 @@ Copyright (c) 2023-2024 Alexei Sibidanov. The original version of this file was copied from the CORE-MATH -project (file src/binary32/acos/acosf.c, revision 61d7bef). +project (file src/binary32/acos/acosf.c, revision 56dd347). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -28,6 +28,7 @@ SOFTWARE. #include #include #include +#include #include "math_config.h" static __attribute__ ((noinline)) float @@ -66,7 +67,7 @@ poly12 (double z, const double *c) float __ieee754_acosf (float x) { - const double pi2 = 0x1.921fb54442d18p+0; + double pi2 = 0x1.921fb54442d18p+0; static const double o[] = { 0, 0x1.921fb54442d18p+1 }; double xs = x; double r; @@ -87,7 +88,10 @@ __ieee754_acosf (float x) }; /* Avoid spurious underflow exception. */ if (__glibc_unlikely (ax <= 0x40000000u)) /* |x| < 2^-63 */ - return (float) pi2; + /* GCC <= 11 wrongly assumes the rounding is to nearest and + performs a constant folding here: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57245 */ + return math_opt_barrier (pi2); double z = xs; double z2 = z * z; double z4 = z2 * z2; diff --git a/sysdeps/powerpc/fpu/libm-test-ulps b/sysdeps/powerpc/fpu/libm-test-ulps index 89dcef3603..07b91f8534 100644 --- a/sysdeps/powerpc/fpu/libm-test-ulps +++ b/sysdeps/powerpc/fpu/libm-test-ulps @@ -8,13 +8,11 @@ ldouble: 1 Function: "acos_downward": double: 1 -float: 1 float128: 1 ldouble: 3 Function: "acos_towardzero": double: 1 -float: 1 float128: 1 ldouble: 3 diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps index 624186f3f6..ad936ad32f 100644 --- a/sysdeps/x86_64/fpu/libm-test-ulps +++ b/sysdeps/x86_64/fpu/libm-test-ulps @@ -8,13 +8,11 @@ ldouble: 2 Function: "acos_downward": double: 1 -float: 1 float128: 1 ldouble: 2 Function: "acos_towardzero": double: 1 -float: 1 float128: 1 ldouble: 2