From patchwork Thu Dec 28 17:20:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1880925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=HAgC43CF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T1FkC3ktsz23d7 for ; Fri, 29 Dec 2023 04:24:35 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C9743858C36 for ; Thu, 28 Dec 2023 17:24:33 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 2279F385842C for ; Thu, 28 Dec 2023 17:20:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2279F385842C 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 2279F385842C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; cv=none; b=hWbjip6P/6m23UFMTJyB3c6/AQWfl7sHyOuvxVPqKtGhRGovT7o/aaN+9Xz4Pdk365F+BmbDmVSihUWFSSN7zvX/dLrzXiI44MBneiKtSoPxb7GU/piUWhyUrUSyEmveyyYi2L8IjA5ZJiMzxOlrTN6AhsSWyytLBOBexltMPa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; c=relaxed/simple; bh=Fyf/Ec11BxuJoVcKbZMh9bSiwbRwSaF+LgXnKbza1ec=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=nhnmu1y9zb//deB+0vkeNXy8mro8ngp78FUv4OU9SLrzD9HA3Odc5b3r2brBKEFuIu5S7WDMkebZvGRlxKDc3IqOCBxjSy/qmPpyoJ+6h6elY6nQmAz1w5ID5hjEpbZA5qhdJRgVoIaCrKCwZUf6dGrZEBWe4aSLfeoeeivHWfk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6da202aa138so503178b3a.2 for ; Thu, 28 Dec 2023 09:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784047; x=1704388847; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=E7XT36BDRDRv2ECRkleLFmh2oLzr2LBN3XN55zu8I98=; b=HAgC43CF9fzxzztqH1plIs90oARd7bvVCIRGpktj8r4/S807oGf0zRPTNyqd2CqdN0 7Bx/K7npnwNeXnYm6wAxQJ4ldqjdlkTFOkkunt+zEKBa+INvSWDqt06ieGOImFQB+0Mr RxJifIa/fauXAxgaiEHPCJVoKzJz7MbbyJmIkon5iP+CaK/fFrznWpDATSCkil+8J9DH 9Ok9ZKWi7y8aqa92qi67Nm+EoKgAa9x6Cjt1XsoZK/DGAbAdysi0pyf1st25K6ll3gCO P9guPr9KbLPmadPdNHDFWuWqLq5a1YbFdUCW15OzA9jIdlwfWqJ8DEzuqlgalT7bimdW GW1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784047; x=1704388847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E7XT36BDRDRv2ECRkleLFmh2oLzr2LBN3XN55zu8I98=; b=QwHqZtdsbvjeTFnj4G2+QDXpdEZPtLzEeSlat3+GAGKIGYYisvV1DTo03dMkQBu7iE XQ+wULbK2IVxCz0b8fJ8vY5PoxcNYq4sMznEjRVANmAi6YsGqM4oLIrB88acobLIwuDL fcs7Q9gYARrdnBBIVGTSQGjOqjX7mpg9KYCAudMvlO6AMYkROujtO+ozqOdSypMq/g+n U9AuGZdNCXDroGkSNpopl3nFloD2o36VXv6Hwt8h4BSorK9Wx6ta3ZcQyeYlv2RjJUXG /Pb/TyLB01vRTsUAXeFBVYD3/2a3NCevVHtdRPPDfsVpKIGsi1JgSud8hjEyhwAcQIk7 VVUA== X-Gm-Message-State: AOJu0Yy8/UXFePx86MNxyLo3sj8KBE9FjkORZfJ/oHwNnTpuDFznp5EU ZKImo7QvWEV7jydrSCDmP/0eLcyYZM9bKDQtVSEWA1xRVJ4= X-Google-Smtp-Source: AGHT+IHCjtb/YruFJbopFGK7c8jYWBsHyQkARb00REpT/zz3sP/3hB/+e3Q1zdkWuP69LQEJoFANhQ== X-Received: by 2002:aa7:90d8:0:b0:6d9:aa94:a38b with SMTP id k24-20020aa790d8000000b006d9aa94a38bmr7859888pfk.5.1703784046618; Thu, 28 Dec 2023 09:20:46 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:46 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 10/12] x86: Do not raise inexact exception on floor/floorf Date: Thu, 28 Dec 2023 14:20:24 -0300 Message-Id: <20231228172026.2013007-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_floor.S | 34 --------------------------------- sysdeps/i386/fpu/s_floor.c | 38 +++++++++++++++++++++++++++++++++++++ sysdeps/i386/fpu/s_floorf.S | 34 --------------------------------- sysdeps/i386/fpu/s_floorf.c | 38 +++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_floor.S create mode 100644 sysdeps/i386/fpu/s_floor.c delete mode 100644 sysdeps/i386/fpu/s_floorf.S create mode 100644 sysdeps/i386/fpu/s_floorf.c diff --git a/sysdeps/i386/fpu/s_floor.S b/sysdeps/i386/fpu/s_floor.S deleted file mode 100644 index 7143fdcc9a..0000000000 --- a/sysdeps/i386/fpu/s_floor.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_floor.S,v 1.4 1995/05/09 00:01:59 jtc Exp $") - -ENTRY(__floor) - fldl 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 */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floor) -libm_alias_double (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floor.c b/sysdeps/i386/fpu/s_floor.c new file mode 100644 index 0000000000..90ba61da92 --- /dev/null +++ b/sysdeps/i386/fpu/s_floor.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +double +__floor (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_double (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floorf.S b/sysdeps/i386/fpu/s_floorf.S deleted file mode 100644 index 8fad9c0698..0000000000 --- a/sysdeps/i386/fpu/s_floorf.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $") - -ENTRY(__floorf) - flds 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 */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floorf) -libm_alias_float (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floorf.c b/sysdeps/i386/fpu/s_floorf.c new file mode 100644 index 0000000000..0e7e8223a8 --- /dev/null +++ b/sysdeps/i386/fpu/s_floorf.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +float +__floorf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_float (__floor, floor)