From patchwork Fri Feb 7 17:00:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 106133 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 40F013857C68 for ; Fri, 7 Feb 2025 17:01:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40F013857C68 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=parisc-linux.org header.i=@parisc-linux.org header.a=rsa-sha256 header.s=2021 header.b=FnM9zp4z X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from paco.parisc-linux.org (paco.parisc-linux.org [IPv6:2a02:c206:3015:3002::1]) by sourceware.org (Postfix) with ESMTPS id 7AA4B3858280 for ; Fri, 7 Feb 2025 17:00:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AA4B3858280 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=parisc-linux.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=parisc-linux.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7AA4B3858280 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a02:c206:3015:3002::1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738947659; cv=none; b=RonXqnT/dtjBVFL3RrjyrLoZ92kgYjnxlQJmWgEQJ7LxVILuQyaYyw6PAAfOWpRJT2OQeOACII3w+Y11NoGFEi1/01z5N6ao28xo/ajesN5ylgERaNLJByTIQvTudFdHakHmlQuz8BHtGSlka0vulDHmNBOXq0TjurfxX+W0GiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738947659; c=relaxed/simple; bh=dvrn1b7HPhcrj9GMTam/OjZP+32mwz6QqoUA6P/Ef5c=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=nwPgIi5yKbc3pXgTUfJTXYWEUas2y+pBZhetSKipE3m0HO6Xt/qddAIGW+UPn351/wBetQIdlh7jhVtdjx2LcLpbuZXz01y3nVygKpuCkJfUJb3jgUif5pw3vJJ11MKeo2fauXIht8EJTeSOJZls7MHoEZd3/st98/k+lcHORQE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7AA4B3858280 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=parisc-linux.org; s=2021; t=1738947653; bh=dvrn1b7HPhcrj9GMTam/OjZP+32mwz6QqoUA6P/Ef5c=; h=Date:From:To:Subject:From; b=FnM9zp4z/BERVIszDAC0R0Ofdo3ZKsdRTwibUqQrniBmUZsL7cFbYjoZYxPYFjXQO Vriyd6YlhcQ0URgDyqzIWzAsQsd10RDG8u60etouOPASV/lnTGdxgNPBWXfvs4qSjQ 2wPMNJ2ExFh3BD5VmDL2waZVcijhxfmiO0uIKnf0lPbD4x0eDpYVYovyTmD/FgEsA8 +tf40D/P8tKrnmlcL4zrsGwZfsWWb+nmsz2BPKtwVXrQLTMQu3v1Zh/87XuWjsgomw llNCCNLwB+BHIJFpGvtbzUh22kplMQ1KggI/Xutb8PBP445GlqynIhLhBr6A05cjgy UCPRxDUzsIHQw== Received: from mx3210.localdomain (unknown [142.126.150.186]) by paco.parisc-linux.org (Postfix) with ESMTPSA id 885EE17E11D6; Fri, 7 Feb 2025 17:00:53 +0000 (UTC) Received: by mx3210.localdomain (Postfix, from userid 1000) id 69A8FD60746; Fri, 7 Feb 2025 12:00:30 -0500 (EST) Date: Fri, 7 Feb 2025 12:00:29 -0500 From: John David Anglin To: libc-alpha@sourceware.org Subject: [PATCH] math: Add optimization barrier to ensure a1 + u.d is not reused [BZ #30664] Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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~patchwork=sourceware.org@sourceware.org This patch fixes the test fma fails seen on hppa with gcc-13 and later. There may be more instances of this problem still lurking in sysdeps/ieee754/dbl-64/s_fma.c and other similar files. Whether they occur in practice is very hardware dependent. I'm not able to test changes to any other files on hppa. Okay? Dave Reviewed-by: Adhemerval Zanella --- math: Add optimization barrier to ensure a1 + u.d is not reused [BZ #30664] A number of fma tests started to fail on hppa when gcc was changed to use Ranger rather than EVRP. Eventually I found that the value of a1 + u.d in this is block of code was being computed in FE_TOWARDZERO mode and not the original rounding mode: if (TININESS_AFTER_ROUNDING) { w.d = a1 + u.d; if (w.ieee.exponent == 109) return w.d * 0x1p-108; } This caused the exponent value to be wrong and the wrong return path to be used. Here we add an optimization barrier after the rounding mode is reset to ensure that the previous value of a1 + u.d is not reused. Signed-off-by: John David Anglin diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c index 20f617b996..42351c6b34 100644 --- a/sysdeps/ieee754/dbl-64/s_fma.c +++ b/sysdeps/ieee754/dbl-64/s_fma.c @@ -244,6 +244,9 @@ __fma (double x, double y, double z) /* Reset rounding mode and test for inexact simultaneously. */ int j = libc_feupdateenv_test (&env, FE_INEXACT) != 0; + /* Ensure value of a1 + u.d is not reused. */ + a1 = math_opt_barrier (a1); + if (__glibc_likely (adjust == 0)) { if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7ff)