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: 758608 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4116045wrw; Thu, 28 Dec 2023 09:24:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHb+ZEkXVNAm0mgy/suaUIGswklbMXOglFkx1AqRPRpabJsn2za05bDg74uS3NrrXSW88yl X-Received: by 2002:a05:620a:15b5:b0:781:481a:ad1a with SMTP id f21-20020a05620a15b500b00781481aad1amr8022856qkk.54.1703784268360; Thu, 28 Dec 2023 09:24:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784268; cv=pass; d=google.com; s=arc-20160816; b=QUqMSlFqYL6CtnA85c1ZVpofK7+vEQCItb4nNwkfNXkEN+xQ3dRhIoFvQP7BDEv0gI SStLHQll5qg9Np570KT5sJcWC8rGmDyHShYmdktYKPL7m10W0Jtrg3nRj7kDeXJU5Nuv hCE1Rw9hIpexQsppRYDwGeI+6q3c0H+nTimkXPRFHz8OAD88VzRj6YBUAh9RbDVpTNzD UYTu6KZZbiAYLUertojGVra2SKH81La6PRuNWFIQpS6fPjAaaJIRPN2wiaCP3I1aNB3d QERB2Omj6yJASAXkqZ8eCx+lQno37ViC1II/aHcNe5PHwaDyDPDdHbKIucUx3xkIq6a3 lYYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=E7XT36BDRDRv2ECRkleLFmh2oLzr2LBN3XN55zu8I98=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=ljNYprYx7sOhlJUenOjnvhyL/rA9+DbQLcsmXxMBUv3jQ5waHg2Vv8Az6sTwJ4OwkH XRVA6qFcJgHg4nxSWRtk7+yIdiH4gBOxdfFCeTZbJNQgOyY/mFvw+oaodDTVUu7R1vWO gscPfOVfLMRyfdHkvATRxZKWNJxFd+fyjd+n5j6SI7BIZPuuqO59clXnOdugdpuWOD7p FCygroC7+ptTYRBGbNqVxW114rFLrHfTiMMSQvjcy6weM7Jb8zn6G1Jr8T9soe9n8lwI J7O6W18Qdwf/t2GMI4KP2P68TAAbsU7B7ydhAyT2o039OA8EKD4FhkVMwxJoMzwIo8g6 nlRg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HAgC43CF; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v24-20020a05620a123800b007811b138946si16489690qkj.751.2023.12.28.09.24.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:24:28 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HAgC43CF; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA56D3858296 for ; Thu, 28 Dec 2023 17:24:27 +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-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+patch=linaro.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)