From patchwork Thu Dec 28 17:20:22 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: 1880923 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=ygkCwpnG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4T1Fhz1Yvyz23d7 for ; Fri, 29 Dec 2023 04:23:31 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C17038582A9 for ; Thu, 28 Dec 2023 17:23:29 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id EB19C385829F for ; Thu, 28 Dec 2023 17:20:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB19C385829F 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 EB19C385829F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::536 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784048; cv=none; b=RSAfK6lcOS+aGQpnarAXQJ2DgvaFj4RAcc2YrI1OBnln9jQK504hD7V4JlGoBwdQkSq4VKvtxUQC+l1K6yhN0Okj6Q6tl7VYEMr7DBTGhzkQlKrSV3ntrZ1kzdDWK0BrVH5kKf8/1ZuzFV3habzbac5fBLnU+UIetqFXpIJt8Cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784048; c=relaxed/simple; bh=lnHACzmx0VPJkz/RKocha4/9EZ6Ug05fxfsGdijW3pA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=vzwp/sbi267Ir0LBQhw4aH540lgDuZTBcmPkho4KBzwhOLPhX1FojjM9qXe40EtNocjGrI6N8vX6Gw5zC0ncGmJXIeqy3qShrrcwqnEkPqyj+IADc4ghwdsE+YoGzHZrXJdlyidh0o1W02SHAUL+3y7q3aaddSbhj1NGGAuDMec= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5cd8667c59eso4686883a12.2 for ; Thu, 28 Dec 2023 09:20:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784043; x=1704388843; 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=wWgi00RdRAG3+ge5c7GtYVas/IOMOL1HlHbPRCVFcDc=; b=ygkCwpnGMJKFQy8UAzN2zLa/oKdDiUHJsl7qLxPsoxtuwgyEujGy0II7ym5/ZNu6Th L/aeAnimDe36HcWEEl/OO+srDtTvAJURThB0eF9/tQ6pnl5GuyID/RTHXmBT5BWlJJIV Y0IuPfs6SyYdlpvvBt1PTVGJDvWAREaZamaOSMnRWI2pVkuP8Ui3kf6tJwUK4u4nHGQl 6G0PKQPGT+BNBdD2vVJeP0C5/w9FuP+Plp1yy3ABbFYAgulZ3XMR1llS4GT2g/GEoMvB D4bIBR6fJFxOMM+TURJjRv2xnFEv+bG5mtYdABatF9Ynxzw1SscACUuIoFKQ46WQHX50 T69Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784043; x=1704388843; 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=wWgi00RdRAG3+ge5c7GtYVas/IOMOL1HlHbPRCVFcDc=; b=ZPsYKXm/dEm7Jh9DxH7P/pCEEdKA5dKtCZCPC6F4R4041C4Iu1X2roGWZSdo3oj9E2 N+zaCNn26fQ+TtHCSoIMkxa+KRGThfslrj0XLYEPdghlO1mRT4kk06eJvVC3eZ66MuRt zuKS4Z6MYb3ReRhywMhShEPcS9TNcdYlZDihuRo8Nxflgi2y2UVXLUg9IQinhOU6HGYZ baPCcS2AT70rSi9jyIy1VH5vmid63MBXwREYF4hodgjXKeeHHuH7C7GC4RbW6Y/o8glX 663EuZ7Eh0Cws82fzz0Vh7PLhVWVW5JMJVNxwZoofkHX6lJp1jvB1ERoU0Cc4xcLEowC KPgQ== X-Gm-Message-State: AOJu0Yzk5AqarLYLuws3mPg7mLXxniI0opX1vQWkv7Lr5otSRwDhPB0W 7oZaRGXqUV9rdb4a8/Cjd+OKcScJRPMPvN7xBivwz+E22E0= X-Google-Smtp-Source: AGHT+IHvi4n6gWixn3VdHvcfYG7rkfm+xkwnH0I3sISUsrhvYy66AjjdU0mcSeR5zopqj1ERN5FWig== X-Received: by 2002:a05:6a20:7d83:b0:196:376c:fb73 with SMTP id v3-20020a056a207d8300b00196376cfb73mr2481823pzj.49.1703784043551; Thu, 28 Dec 2023 09:20:43 -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.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:42 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 08/12] x86: Do not raise inexact exception on floorl Date: Thu, 28 Dec 2023 14:20:22 -0300 Message-Id: <20231228172026.2013007-9-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_floorl.S | 39 ----------------------------------- sysdeps/x86/fpu/s_floorl.c | 38 ++++++++++++++++++++++++++++++++++ sysdeps/x86_64/fpu/s_floorl.S | 33 ----------------------------- 3 files changed, 38 insertions(+), 72 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_floorl.S create mode 100644 sysdeps/x86/fpu/s_floorl.c delete mode 100644 sysdeps/x86_64/fpu/s_floorl.S diff --git a/sysdeps/i386/fpu/s_floorl.S b/sysdeps/i386/fpu/s_floorl.S deleted file mode 100644 index 3ec28b477b..0000000000 --- a/sysdeps/i386/fpu/s_floorl.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: $") - -ENTRY(__floorl) - fldt 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 */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floorl) -libm_alias_ldouble (__floor, floor) diff --git a/sysdeps/x86/fpu/s_floorl.c b/sysdeps/x86/fpu/s_floorl.c new file mode 100644 index 0000000000..edaf5e954f --- /dev/null +++ b/sysdeps/x86/fpu/s_floorl.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. x86 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 + +long double +__floorl (long double x) +{ + fenv_t fenv; + long 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_ldouble (__floor, floor) diff --git a/sysdeps/x86_64/fpu/s_floorl.S b/sysdeps/x86_64/fpu/s_floorl.S deleted file mode 100644 index b74d1a4d6b..0000000000 --- a/sysdeps/x86_64/fpu/s_floorl.S +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -ENTRY(__floorl) - fldt 8(%rsp) - - fnstenv -28(%rsp) /* 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 -28(%rsp),%edx - andl $0xf7ff,%edx - movl %edx,-32(%rsp) - fldcw -32(%rsp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - - fldenv -28(%rsp) /* restore original environment */ - - ret -END (__floorl) -libm_alias_ldouble (__floor, floor)