From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by sourceware.org (Postfix) with ESMTPS id 921133858D28 for ; Mon, 1 Apr 2024 14:14:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 921133858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 921133858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711980878; cv=none; b=oy2mMIhWP08aZElvzdXqnMJV+3+Tl9ToZ9Cvw+hAO9vXJg8YVk5gs0UjLChQ5yyi4oed3PvCom1XGmL2Rn0zxYJWyBqIybPvM/7kzPWmFjyUrj1P1xovnJaMiroTM+hs6IytZEL7kMt9BssE9XLj/dHXJmT8uP5ZNhXguDjt5Sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711980878; c=relaxed/simple; bh=jcGphAmJ/QS9L8TGToB+1yDZnD8Hy/2ySeZO6pbmd3Q=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=qGf98N7t5rjyPybuhPxGEkXjMWWCt3gdP2MkN1rj38iYPhGWzQyTwLQ+N35fYpp5JB0jC/WSuswVSW/jMPrrEkXkXvfuafxbN1ZKlFjfOZ0IOj5DGxBpm6SiCgU844tleZK/MCdp4YSx9HwsPsXD54QIR45fHBkuPV9Cpg8EGjU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-dc23bf7e5aaso3729996276.0 for ; Mon, 01 Apr 2024 07:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711980876; x=1712585676; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PSa3vPv2Frx2MdUkaFtfgySVwk0ahJCEQcdGVOOvwJE=; b=UdFatfns1BJOekMIMCWvYyHfURLKCZSINoKXimZv3TWXdrhPhm4iFlqnv55wF24zEx eLsfVAlEFyfGqPqmAF5wkKibJIZBPw+bNSOSdGExg5KmwuGM1AJZd/uJhjuOqHnqVudg +n3w67Xl2B5MBnN6OCQLxg6Efr80N1aKpnr5FBriBiMNKv2X5e+dlpG7snYGA6NQWLib RwYCAwxssOLOmgnssGejddxEVTnlynBZKTSD9QWlWtGn9tprWwloHSPKUgTpspYSgtLc pD6MSLe96wyPdJc09zStSaTjElaKx6gtKVhF0ZoWH9GSlylZtKF4+X2y1JXh8FDew4jl 2brw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711980876; x=1712585676; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PSa3vPv2Frx2MdUkaFtfgySVwk0ahJCEQcdGVOOvwJE=; b=K5fRdWlph7FULFEeiHHJGONdJQi1f/nsepC72lPg24+68miw/zRDYOvPhamVp3+9Um IfNpO32bem/5en5UNVgAkLzWPBgfUwkaQk2KSBt6KSrzO9+OO899RIk7K3rK+7vBvzBH g/mN00V/Zukrnkxmr6YD1E6ZhIZtEIl+MWsSfYwlw6KMV3/Rw2htcVV/5+G04dG0L+Tp YhH9zCd5ASxwg4mpLrtPUxvM98F+bwiIMJ030YSvWjv8yOcDeKuTpevDD7Wm5lhEBzt3 veiCwe96hfzwlpPwUsXYEnsxWF27os3L8SlhviMBKnXnLRX5h+4IDqMf2XgDEOCA7fhm Ggbg== X-Gm-Message-State: AOJu0YwT2cdbDnn52SI73xgnX6b9ta59jp96MLaJGxfXoziIckZxW5go XHbpKDN2J1bvilWmzz2nBvdSCzUwHR/QU7Vwa9qnFdtj8shH2UqWJqb0sFvWuiCqPg4UyxEaFE6 i7anBzPRpCIRgV9D0E7WvL6CXR9y3Mb2v X-Google-Smtp-Source: AGHT+IHjtTKkrLnGJva+iPhTQJFHytk+p22FAXY8kZBSPc0jbHicXJBgRQ8yw4EQW9bhHHWDTol2hHLaQtV06GgW6BY= X-Received: by 2002:a25:7e43:0:b0:dcc:56b6:6606 with SMTP id z64-20020a257e43000000b00dcc56b66606mr8123591ybc.40.1711980875923; Mon, 01 Apr 2024 07:14:35 -0700 (PDT) MIME-Version: 1.0 References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> <20231228172026.2013007-9-adhemerval.zanella@linaro.org> In-Reply-To: <20231228172026.2013007-9-adhemerval.zanella@linaro.org> From: "H.J. Lu" Date: Mon, 1 Apr 2024 07:13:59 -0700 Message-ID: Subject: Re: [PATCH 08/12] x86: Do not raise inexact exception on floorl To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3019.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On Thu, Dec 28, 2023 at 9:23=E2=80=AFAM Adhemerval Zanella wrote: > > It is not allowed anymore on ISO C23. > > Checked on x86_64-linux-gnu and i686-linux-gnu. > --- > sysdeps/i386/fpu/s_floorl.S | 39 ----------------------------------- > sysdeps/x86/fpu/s_floorl.c | 38 ++++++++++++++++++++++++++++++++++ > sysdeps/x86_64/fpu/s_floorl.S | 33 ----------------------------- > 3 files changed, 38 insertions(+), 72 deletions(-) > delete mode 100644 sysdeps/i386/fpu/s_floorl.S > create mode 100644 sysdeps/x86/fpu/s_floorl.c > delete mode 100644 sysdeps/x86_64/fpu/s_floorl.S > > diff --git a/sysdeps/i386/fpu/s_floorl.S b/sysdeps/i386/fpu/s_floorl.S > deleted file mode 100644 > index 3ec28b477b..0000000000 > --- a/sysdeps/i386/fpu/s_floorl.S > +++ /dev/null > @@ -1,39 +0,0 @@ > -/* > - * Public domain. > - */ > - > -#include > -#include > - > -RCSID("$NetBSD: $") > - > -ENTRY(__floorl) > - fldt 4(%esp) > - subl $32,%esp > - cfi_adjust_cfa_offset (32) > - > - fnstenv 4(%esp) /* store fpu environment */ > - > - /* We use here %edx although only the low 1 bits are defined. > - But none of the operations should care and they are faster > - than the 16 bit operations. */ > - movl $0x400,%edx /* round towards -oo */ > - orl 4(%esp),%edx > - andl $0xf7ff,%edx > - movl %edx,(%esp) > - fldcw (%esp) /* load modified control word */ > - > - frndint /* round */ > - > - /* Preserve "invalid" exceptions from sNaN input. */ > - fnstsw > - andl $0x1, %eax > - orl %eax, 8(%esp) > - > - fldenv 4(%esp) /* restore original environment *= / > - > - addl $32,%esp > - cfi_adjust_cfa_offset (-32) > - ret > -END (__floorl) > -libm_alias_ldouble (__floor, floor) > diff --git a/sysdeps/x86/fpu/s_floorl.c b/sysdeps/x86/fpu/s_floorl.c > new file mode 100644 > index 0000000000..edaf5e954f > --- /dev/null > +++ b/sysdeps/x86/fpu/s_floorl.c > @@ -0,0 +1,38 @@ > +/* Return largest integral value not less than argument. x86 version. > + Copyright (C) 2023 Free Software Foundation, Inc. 2024. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#define NO_MATH_REDIRECT > +#include > +#include > +#include > + > +long double > +__floorl (long double x) > +{ > + fenv_t fenv; > + long double r; > + > + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); > + asm volatile ("frndint" : "=3Dt" (r) : "0" (x)); > + /* Preserve "invalid" exceptions from sNaN input. */ > + fenv.__status_word |=3D libc_fetestexcept_387 (FE_INVALID); > + libc_fesetenv_387 (&fenv); > + > + return r; > +} > +libm_alias_ldouble (__floor, floor) > diff --git a/sysdeps/x86_64/fpu/s_floorl.S b/sysdeps/x86_64/fpu/s_floorl.= S > deleted file mode 100644 > index b74d1a4d6b..0000000000 > --- a/sysdeps/x86_64/fpu/s_floorl.S > +++ /dev/null > @@ -1,33 +0,0 @@ > -/* > - * Public domain. > - */ > - > -#include > -#include > - > -ENTRY(__floorl) > - fldt 8(%rsp) > - > - fnstenv -28(%rsp) /* store fpu environment */ > - > - /* We use here %edx although only the low 1 bits are defined. > - But none of the operations should care and they are faster > - than the 16 bit operations. */ > - movl $0x400,%edx /* round towards -oo */ > - orl -28(%rsp),%edx > - andl $0xf7ff,%edx > - movl %edx,-32(%rsp) > - fldcw -32(%rsp) /* load modified control word */ > - > - frndint /* round */ > - > - /* Preserve "invalid" exceptions from sNaN input. */ > - fnstsw > - andl $0x1, %eax > - orl %eax, -24(%rsp) > - > - fldenv -28(%rsp) /* restore original environment *= / > - > - ret > -END (__floorl) > -libm_alias_ldouble (__floor, floor) > -- > 2.34.1 > --=20 H.J.