From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 9E61A1F44D for ; Mon, 1 Apr 2024 14:15:47 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MjwIoTCD; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E43473858C32 for ; Mon, 1 Apr 2024 14:15:46 +0000 (GMT) Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by sourceware.org (Postfix) with ESMTPS id 9AD7D3858D28 for ; Mon, 1 Apr 2024 14:15:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9AD7D3858D28 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 9AD7D3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1133 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711980930; cv=none; b=visbUn4BkvlPSp4op4l9NXqJM5jI8hXe74/FMYRTILx+P4u/xVEe/35ajUpq30mIhf3UJOlvugLFqxYwNaVITQ7H+WBkNdf3KkA2nmh8J9d0UtPgZ1Vozqd8kr++xF2oTFaj0vuTgVuAuI7D6G/vZfLVV1wW2PtI/JtjYA8VTQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711980930; c=relaxed/simple; bh=ArkChYqH4uqjE2lB98Poggs3u69S+66VWhCxugNlmyA=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=mUVg8LSvJb6346TOH0qeRDB0xwe4hWi7c3BThZ4muZUWJPcu1syyMFzNfE0xvPeuYD1m21RVaKdvDOOdlBKdJsKrfetWiDSGC/BiRKgfzxUxMtX3CKr9BdzSs88lOmHW+JO58AgizUZHhVBge1OWm0aQQi72ZBfatdWdv3bqQT4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-6150670d372so2110227b3.1 for ; Mon, 01 Apr 2024 07:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711980928; x=1712585728; 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=CplJjvRfGvQOv80xPdRoiEs9BGIKjYc/VqDLSfbV0ik=; b=MjwIoTCDGecuTbkzT7Z/zJatXLJcmpQPxITEw/KYmplHrntiJnd8mB8NKbtliNdodq aKk9Z0cnzrqbRSdwhQFFc6gOrTzdg9ytSPfAoFOovh/XqVu/NiY/yyeTN+8cP66C1O6j wTyihKZ3mC4yj+39KZIKk767Q7LeSdQJ0kGGaeB356TOkY6q9IRhhbr+N2+dEEbMgtzW nh918/o4c09k+W/ZWCD2ZVm45q0EGW1FTjV6T+/QGdgvB75UOfadD1T5rL14EPdj2r3C fnUFlHuFwX10P9ag6WLncDIlS/Eo/vJoTrrbxtxVnCoxDNCIisNneXZLciwufschApoH hOOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711980928; x=1712585728; 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=CplJjvRfGvQOv80xPdRoiEs9BGIKjYc/VqDLSfbV0ik=; b=IJl0WsqG+rws3C8CABowhiw9bzqhmDMCLVPklH4d3RuG33boBvDlXdDjL+tjnfcOFa yOPGcahvzgpmDQKrIALdphg4P54vY/YSjLTafAZlwxjcz8ub4T9N9Bvo2Wy+iMltvHbO Ozeo0b/+7SIFJb4L68k/+K8gZS3st0YA8bn34YP41uCUOB+Y3HTlmgQgQovogaNdrdVf nYvomYfR4mnp2/CXsFKhwdP4zsow5BadygaDfR9uw+/1Svd+JmYBhqqs/wNOCiY96kXw oiJlf134qkn44I2cXZTHTmF/7mdobaXCjbavy+mtz5+u4dt2TERnf74/VyRbtxJk225D Jh1g== X-Gm-Message-State: AOJu0YzpCGrRi9XqliE4gftIL3MzYV8HP5SWehzfbVNLkh5D7Dug9RGh WL/x6Hr+KsWmuSk9YodjP2QeIfs9+u9Vc3KydEbc7ZyV9rdZOBkIEAhG7hPxPodgyPId6qScM1K aAhYdbLKNwSDecOkzZSHkIhEgT3k= X-Google-Smtp-Source: AGHT+IEqctlY121aL+vBX873ULO6rYN3Dx6/0HAyapNRDzXmxbRVLoXjskDK7D0++mWkDBjmT8oOGD5Mmvoarb9nGyY= X-Received: by 2002:a0d:dec6:0:b0:609:1252:61e2 with SMTP id h189-20020a0ddec6000000b00609125261e2mr8474661ywe.45.1711980927902; Mon, 01 Apr 2024 07:15:27 -0700 (PDT) MIME-Version: 1.0 References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> <20231228172026.2013007-10-adhemerval.zanella@linaro.org> In-Reply-To: <20231228172026.2013007-10-adhemerval.zanella@linaro.org> From: "H.J. Lu" Date: Mon, 1 Apr 2024 07:14:51 -0700 Message-ID: Subject: Re: [PATCH 09/12] x86: Do not raise inexact exception on truncl To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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+e=80x24.org@sourceware.org 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. > --- > .../fpu/s_truncl.S =3D> x86/fpu/s_truncl.c} | 40 +++++++++---------- > sysdeps/x86_64/fpu/s_truncl.S | 36 ----------------- > 2 files changed, 19 insertions(+), 57 deletions(-) > rename sysdeps/{i386/fpu/s_truncl.S =3D> x86/fpu/s_truncl.c} (61%) > delete mode 100644 sysdeps/x86_64/fpu/s_truncl.S > > diff --git a/sysdeps/i386/fpu/s_truncl.S b/sysdeps/x86/fpu/s_truncl.c > similarity index 61% > rename from sysdeps/i386/fpu/s_truncl.S > rename to sysdeps/x86/fpu/s_truncl.c > index cfd4e75252..249b307004 100644 > --- a/sysdeps/i386/fpu/s_truncl.S > +++ b/sysdeps/x86/fpu/s_truncl.c > @@ -1,5 +1,5 @@ > -/* Truncate long double value. > - Copyright (C) 1997-2023 Free Software Foundation, Inc. > +/* Round to integer, toward zero. 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 > @@ -16,25 +16,23 @@ > License along with the GNU C Library; if not, see > . */ > > +#define NO_MATH_REDIRECT > +#include > +#include > #include > -#include > > -ENTRY(__truncl) > - fldt 4(%esp) > - subl $32, %esp > - cfi_adjust_cfa_offset (32) > - fnstenv 4(%esp) > - movl $0xc00, %edx > - orl 4(%esp), %edx > - movl %edx, (%esp) > - fldcw (%esp) > - frndint > - fnstsw > - andl $0x1, %eax > - orl %eax, 8(%esp) > - fldenv 4(%esp) > - addl $32, %esp > - cfi_adjust_cfa_offset (-32) > - ret > -END(__truncl) > +long double > +__truncl (long double x) > +{ > + fenv_t fenv; > + long double r; > + > + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); > + 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 (__trunc, trunc) > diff --git a/sysdeps/x86_64/fpu/s_truncl.S b/sysdeps/x86_64/fpu/s_truncl.= S > deleted file mode 100644 > index 8d319e68b0..0000000000 > --- a/sysdeps/x86_64/fpu/s_truncl.S > +++ /dev/null > @@ -1,36 +0,0 @@ > -/* Truncate long double value. > - Copyright (C) 1997-2023 Free Software Foundation, Inc. > - 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 > - . */ > - > -#include > -#include > - > -ENTRY(__truncl) > - fldt 8(%rsp) > - fnstenv -28(%rsp) > - movl $0xc00, %edx > - orl -28(%rsp), %edx > - movl %edx, -32(%rsp) > - fldcw -32(%rsp) > - frndint > - fnstsw > - andl $0x1, %eax > - orl %eax, -24(%rsp) > - fldenv -28(%rsp) > - ret > -END(__truncl) > -libm_alias_ldouble (__trunc, trunc) > -- > 2.34.1 > --=20 H.J.