From patchwork Wed Apr 3 12:11:46 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: 785432 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp282664wro; Wed, 3 Apr 2024 05:13:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUYZvh0rNPoJiRS5Oxg29IK+SYe99cq1tRarjIqkiqVmQHOHjCrBDIcUjZh5FRgDUeK3T3wd9B9dLG6IQD/nhW X-Google-Smtp-Source: AGHT+IFwPw70bcigUz0osHoI0oc93kU6bzvW76/xwU+A9qG7Fa4O+Q8v/TolW3m1sX9f3kpff//f X-Received: by 2002:a05:6808:2e4b:b0:3c3:f737:99b with SMTP id gp11-20020a0568082e4b00b003c3f737099bmr17994618oib.19.1712146395653; Wed, 03 Apr 2024 05:13:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146395; cv=pass; d=google.com; s=arc-20160816; b=hyg7hO1v8Ih3UJIGv4CwXhkFkhewzRIa4EwXfyMxAQBLOYqDRgVsEp3EVoGbWfCTgD MMYBElHd54iaRHF+9i4XplSntFS6pJ1aII3K6gQSE21mUZIyV0oQ/rpSxcF9BgPldLJy Rntk4c+/XQh69bw31UV9vMlwpuvNpOwJht0rcK+6GOyTCbFbb4+dx4IXyycD+Xc3F4JB e8QiYqAnVNCTjXvR3Yd1mCaCH78h5X6b/5H8dcW/KhPsgg/x8zma04wflyPUfQPGcWy0 qWsDNBQ1WJX1XTdbzYMQVlKJbfflnZFPwiVD4+tSObV02bpQTQghnKz7tH4i64RiZ5fL P8sg== 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=FQ5rLm032Y5QqQskna1qADGnTVJQSJ0WGlTt4XHwCYk=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=CSwcRK34aV60kIShnRD2uhGmT8mzLSBSL6fjQpNXyJfKrDaj9uwcv6gkuHi4s3ITui 7T7eufDZAg2UVhKGyFlEKPKbJ54XS+CSXcFGQYQM5BcNLXSuRPGHdDmSbhRzu9ZfsQ7P ZtZnRrDBuHVtJmi4J1zKHD13733qn780GKTdWAS5RksKcANd1lJWvf1xQ1Elz0Bjf1MM Dmw37auju3ZaAkGlV11Jb6DnKQfrFpTSwY5N09yDYQ59Sd+VVtaIu2SNits93oSw06ml +co9SWr1iyoFOhI6Pt8DjL7D8fpccdeaYdSg5KCegdYFj4uaV2QKLRTRSwsxnCRcGsF8 aI6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jy+CDZAt; 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 v2-20020a05620a122200b00789cfb8d3b4si14064904qkj.522.2024.04.03.05.13.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:13:15 -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=Jy+CDZAt; 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 090E338460BD for ; Wed, 3 Apr 2024 12:13:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 58BA2384640E for ; Wed, 3 Apr 2024 12:12:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 58BA2384640E 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 58BA2384640E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146331; cv=none; b=gT4Vx51rN34dB+JoFk6cT69g0HTafmFpqNR5AxzYcJUsraLs6kLcdLmS2PGyvUl5JUwNxEt4Z5lSB6l9gf1BZQqdeyHicKZMG2c1VnITMFt7b/pG5HtpxJpa9IOzLtNRNUVuRfsYfp380YmMIJ3d7FIpAqDq5ey2xgXum0c2HPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146331; c=relaxed/simple; bh=FOMDCenPAQlg5NMjQI5UJGbXM22kuiEHG338KjBy7TA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=TYT6YN3wQbDd1ueDK/3OaEpD+MXPVBvaOucgwEqIBgMXLrzDOGGsL8ZhJXnGz997rWexcUz/tPjyama8Bj/GtvvWpGaAA0gbHYv1H5WuWUZMcNV7rGIs8bNxjWW6YdP1ioUN27AJv5lkK0y8VwxNqZiAmhgUtiJyhDHXNw34K4U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2a27ba3b1f3so892081a91.3 for ; Wed, 03 Apr 2024 05:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146325; x=1712751125; 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=FQ5rLm032Y5QqQskna1qADGnTVJQSJ0WGlTt4XHwCYk=; b=Jy+CDZAtGCVliN0/CSdB3bWhtJxF02EgmDYLXPSpwWefvEu6h66K1Wnl2eHQiMUXi1 02Gg5NBbau/fG0WAyjLGv3a5aPfQsJLI+PZfgUb/8AaEGmuTFtVEpNZr/d/Rd8p8hTdi U/PKNBsBpztgS0pdaFJA+8KAvZmIKq34raRUNWOhJFKDbSlXxnM0Jdnw+068aeLsBB7G kpYPkskTivvIwNKXgwmoE1TlUngKm9U4WE83f6faAiRevXnRQqPancCUiWu60bAYPUY/ hN1D7Bp54ncGzcXBDGG8jTsQwQbvTRBfBAwdOxH+cMBIa5tcZdCOnic06CwRrJnYm+PN yB7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146325; x=1712751125; 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=FQ5rLm032Y5QqQskna1qADGnTVJQSJ0WGlTt4XHwCYk=; b=WfzvA64GpzzgqVgnLHZrpp9gvisKEj8kRgKVb+vOCag8azI7CusVIjGhMv6Qt4Zsdu Q6a7QCKcAZSUCJ8tpmZr1Aw+yyBv/OnexNLGPFP7NcvF8yJZ57FphZo8WwazeJSRrpT8 tLr+0UJxI8WvcZBXjpTBVZe2WRs4Y5Sg3QSuWdfG96OQx+6/ZFrC5qVhTU+8Q1fSU1Ad 2aFIZm2zLFolzi+6MZa/T+bTqU7Lch0hKZCHHvRMVGO+GNSN2gnj0RAv89j9JCzc1mTu 1PBxYT3KlyegJZMOVGK23M2edavJZJn3r5YQJpG1ze9vfvJu4Px43Ho1YVQR3GeY62js oRsA== X-Gm-Message-State: AOJu0YzLqditofPs+IDK6HiO0p7CDQwXVG8TuP/TY0tAbj3KYAc+0LwS wnBhWmqpXTHb4hnRFGGzzYFruhjR8WC7uyM44I62r2n0zrP7Gcab4MFUlUOFrA3yQwtDbDfjdRn k X-Received: by 2002:a17:90a:f008:b0:2a2:8c6d:17bf with SMTP id bt8-20020a17090af00800b002a28c6d17bfmr1966247pjb.4.1712146324747; Wed, 03 Apr 2024 05:12:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:04 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 06/10] x86: Do not raise inexact exception on floorl Date: Wed, 3 Apr 2024 09:11:46 -0300 Message-Id: <20240403121150.1018799-7-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_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..3eca033f46 --- /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) 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 + +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)