From patchwork Wed Apr 3 12:11:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 785438 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp283434wro; Wed, 3 Apr 2024 05:14:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV93SJCdS/T7FaURMcPmMu9u0FjS32CPAnr5wfnnhfSmHfdM6SCi/PkztfU0j/CjkPJkpORLmKnRoOMam0J9061 X-Google-Smtp-Source: AGHT+IE5yHN1um772kxjVmalBNJWjvqZLDvkXtfR4dp/zOfqrq+HAy7uI1ncnX7x0zrmSylb/EOk X-Received: by 2002:a05:6214:170e:b0:696:990b:dfeb with SMTP id db14-20020a056214170e00b00696990bdfebmr15257376qvb.16.1712146498001; Wed, 03 Apr 2024 05:14:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146497; cv=pass; d=google.com; s=arc-20160816; b=keSzPDXC7UQeELLGNlPNAVjnUakHE8EjKG8KZ2WrI53+uy8fyb4aCCyorg7Tgp4L+6 nhlntzKNj4M7hMj+LZWniU8Ucl7XIvOhkmswSh8sElNbRMBbdomNDVZlvQTzC9MOoFy2 As5rAEvh2CSgZ5YB90Ivs9gJZYM++/eGoHdck+UF73pho5ygS2axpzcUYxq6/PVevxaL cXinidRh+YdgXr+vt6vpG+iKw2NCVcVkGn5RQy/8Y5Ea3NcQWD/B/Sybnr/bci05Q7cV mEqhSjMyP4u3itnJZMihEWAIgxtuPFF6xlhTrsnwC/+Rqm+Lq4ekCPnHN0aN0Dvt0YXH rXOQ== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=J/Hd4wfoUBN6nzKlseuAtLyrP9hg4ATd5bOGXdKfpHA=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=P4pj87wo8jPF6/5zvLofy8ZGm0GwxxrkULF85RNjdhKjNrZDx+4RmqECfmBNqYEpam YEAhtPMeldg0bXQTCe/qv6JOLKb7IOFRyIkLtSeyO6r9OYBZauJhbz7hHkHx1gKziPOP rZah3yn7zEpVrLVkVr29iICw1I0kfp57a+CfczTDkYmUdxyd7FYhExdC1zp+SrlOLrKe OSE1fI7IcBRssSiDIvRUPNSooNrG3tV6LEoT+ZI3f4HUmtBKLNciXFc6jznSzhKeM3k1 NoNcSzNK+J9ev/H5CCR3P4iEQLiA/C+NkVmroLQ/SWESGfb6ry1T0UE6e9eEeam6INuf +93g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CPmePX/c"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id pr21-20020a056214141500b006990ee36c8dsi5163964qvb.488.2024.04.03.05.14.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:14:57 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CPmePX/c"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 90BA53847718 for ; Wed, 3 Apr 2024 12:14:57 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id C8F643846402 for ; Wed, 3 Apr 2024 12:12:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8F643846402 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 C8F643846402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::533 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146333; cv=none; b=KW3qPWft4jnwKWLR4vt6GQPwxPEE0EnYR6M7kcSaGKaimO3/y0iuGhvD11uz1ar/kQuwUC/PwgQhlEONaAlaOocjxXr5ECGcsI7HFoUzOj+EqS7WNz1gXS0uXCPG33/uJ2tuvgo/5zWlCwmuNIWme3WFKRSsyWvv7hLGdVtyBa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146333; c=relaxed/simple; bh=HOTicEWALthATkxUWlUAwWIoeL1jPKakutAyvc6a1x0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=QmZWUGTYQfy+8K90eXcFmj1DdFsb7kgn6A2FGPuuan0wZ2bqUBWQ22BGaS+3ZF5ierNup/J95WVpZ9onRDpLDlQvcsUJ/Mf2RYJepXfNPb1ugszWfZ1tM2QXzh8bc9/HRPVBNWND24+xjr73sGyNH4RhZaawS2nDkjR+53QLWkU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5d42e7ab8a9so3554457a12.3 for ; Wed, 03 Apr 2024 05:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146328; x=1712751128; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J/Hd4wfoUBN6nzKlseuAtLyrP9hg4ATd5bOGXdKfpHA=; b=CPmePX/cIgyo51eYuj3fd5deLqYnLwyQxcGMP7rKQe+GgCpuYteYLGUkMSbaombGJM LI3Yx4a5dJXogrDTlBKdV9A/wOvrpq4OehZVMkskgn+FK/mcSN4Sps7lgPYGgj4l9Lw/ Ys0Ph5a337Zm4HErsCLIn/apOWUtgBIZj4wfSqb8mFm7V4biUZ3Du2BxVhzoZopDNeRM 2gaiu534ey0npGgx6worx/gVGLeMBVH2n4tlykmOJ0w+Np56w0RWojTfEx01wcPd9h9R atZrRPpHIedVpkf+0JvAI/y76s5Yw8G6BuOjrEFAz9UJXzdEjzCaFsDCAoum+IA7AYf6 6JgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146328; x=1712751128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J/Hd4wfoUBN6nzKlseuAtLyrP9hg4ATd5bOGXdKfpHA=; b=SVxPnylcxyO3LDFZKZ/seIn8f3ArphD6MGRh8Cj0OFNUkMa3DUv4+15hOOsHGvbpXV F5rq+1VB2hKk0iOjQma291Ynwq3THbW6z4Bk9AU0OAuW11rqUF+CaNrIVjHSyzB1QIcV U+xdkVyc6B3X7LiiNGit7YMX+/VQghA5HwXV0zc9PFKfE62O7VhxYnJl8MRhpNSiUpId XjmhL4YrvhWMpnMaH9YKeLZNhNb5VDcAFxHYBoPfY/h98IGXAMU57pu2i1od+Ky6i3xg YQb7LQjOP/vGvUDSzEb1bGw+UOXYDu8acbszkviCxn087mlRc5GajrdYkoEaigQP21tu SWKw== X-Gm-Message-State: AOJu0Yz24ITgaOR7diQDABzb/6ipcAM19rewAvnoo4t48Mf323cHvDG0 jBI/QjBvj5Z5MKEROJ6Vyor7Po1Pg9DW8sbLVzCxKW8x2ewykVv26b3cV2Ekysq4j6HyL2sXxvN l X-Received: by 2002:a17:90a:c28f:b0:2a2:648a:74fa with SMTP id f15-20020a17090ac28f00b002a2648a74famr3875034pjt.42.1712146328040; Wed, 03 Apr 2024 05:12:08 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:07 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 08/10] x86: Do not raise inexact exception on floor/floorf Date: Wed, 3 Apr 2024 09:11:48 -0300 Message-Id: <20240403121150.1018799-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-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 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..8e763327ad --- /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) 2024 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..e5ff58c8c6 --- /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) 2024 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)