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 Netto X-Patchwork-Id: 1919294 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=CPmePX/c; 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 4V8kGJ396rz23tl for ; Wed, 3 Apr 2024 23:15:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A1CD6384645B for ; Wed, 3 Apr 2024 12:15:02 +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-Google-Smtp-Source: AGHT+IFzHV+wZ/37D+iz3dc5FTz4NEC1MQTt3Ex5BB8M/szOni+kIQed6vj9nt2TzdBtg4vrqYWtRA== 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+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..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)