From owner-dev-commits-src-all@freebsd.org Fri Jun 25 17:33:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 82A9F667D08; Fri, 25 Jun 2021 17:33:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GBPGk2mtZz4rCL; Fri, 25 Jun 2021 17:33:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 331747649; Fri, 25 Jun 2021 17:33:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15PHX2gM099221; Fri, 25 Jun 2021 17:33:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15PHX256099218; Fri, 25 Jun 2021 17:33:02 GMT (envelope-from git) Date: Fri, 25 Jun 2021 17:33:02 GMT Message-Id: <202106251733.15PHX256099218@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 7356681c6c28 - stable/12 - Fix failures in libm's lround_test after clang 12 import MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 7356681c6c28a02f29f529a353938707d312109e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jun 2021 17:33:02 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=7356681c6c28a02f29f529a353938707d312109e commit 7356681c6c28a02f29f529a353938707d312109e Author: Dimitry Andric AuthorDate: 2021-06-22 16:38:27 +0000 Commit: Dimitry Andric CommitDate: 2021-06-25 17:31:32 +0000 Fix failures in libm's lround_test after clang 12 import It turned out that the (type)DTYPE_MAX conversions at the top of s_lround.c are now emitted as cvtsi2sd instructions, at least on SSE capable CPUs. This caused the FE_INEXACT flag to always be set, at least for the double and float variants. Under clang 11, the whole INRANGE() comparisons were still optimized away, but this has "improved" in clang 12, due to stricter adherence to the -ffp-exception-behavior=maytrap compiler flag. To avoid run-time integer to float conversions, use static constants instead, so they are computed at compile time, and the INRANGE() statements are optimized away again, if applicable. While here, use an integer instead of a floating type to store the test results in lround_test.c, as this is more appropriate, and we can also drop the volatile hack. Reported by: arichardson (cherry picked from commit df3b437c1e073eb83e9a93af1c417f3ee8d0de3b) --- lib/msun/src/s_lround.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/msun/src/s_lround.c b/lib/msun/src/s_lround.c index 66d9183a74bc..c4d305401ac8 100644 --- a/lib/msun/src/s_lround.c +++ b/lib/msun/src/s_lround.c @@ -49,9 +49,11 @@ __FBSDID("$FreeBSD$"); * that everything is in range. At compile time, INRANGE(x) should reduce to * two floating-point comparisons in the former case, or TRUE otherwise. */ -static const type dtype_min = (type)DTYPE_MIN - 0.5; -static const type dtype_max = (type)DTYPE_MAX + 0.5; -#define INRANGE(x) (dtype_max - (type)DTYPE_MAX != 0.5 || \ +static const type type_min = (type)DTYPE_MIN; +static const type type_max = (type)DTYPE_MAX; +static const type dtype_min = type_min - 0.5; +static const type dtype_max = type_max + 0.5; +#define INRANGE(x) (dtype_max - type_max != 0.5 || \ ((x) > dtype_min && (x) < dtype_max)) dtype