From patchwork Wed Apr 3 12:11:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 785437 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp283149wro; Wed, 3 Apr 2024 05:14:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXiGNcsJCYdd6JBhoNcaoqZTcNLbKshYnOcmlfOUycwnTPBCkBBvGruCwkZqYSWRJCULVbSXJf3sJWrYDrSMZOQ X-Google-Smtp-Source: AGHT+IGzZf16yFdkdg+44/Qy6tqOVvvsBoWUEJ43cawWHrXi9AIoi8IhxDyfUuhwCo2TYx6vnrjm X-Received: by 2002:a05:620a:22aa:b0:78a:45b7:2e46 with SMTP id p10-20020a05620a22aa00b0078a45b72e46mr14574959qkh.45.1712146458567; Wed, 03 Apr 2024 05:14:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146458; cv=pass; d=google.com; s=arc-20160816; b=G5rCFh+qM+fjCBR8AvoVkd/C6Fut7+LqwfrrsQIFu0PVb12Z8/rIs8F4kVqa/TaS1b qVAn72K2HIcVoFv65Wxc1qa8ZHEV+JlIH+T41IrDBfH+EpT8s7v2GE8AQq0zPYXJNROF pskN5IZX2qRSw03yBqqzNbgiSSeuDSh5rkVoyUPgHRz4CaYpmB0fBZPsM5tLFwQHK+bf DCxaeC2CsVSVopZL28wlIY77ioL59esgotmTlmXvOj6lHPBtHASNHoJ9BpBKIJUwhdj/ lUcyUjvQSSyZkRdQaF3jnjHQRppudC1TTX0EV7Zmzf2x2iuY8Ub3gykfjXCh9S49BMnN sBag== 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=zlY9goMk06RobzKIAKJy3vjK/nrrQAIbI2heyFcTgXM=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=KxqDbF9ycTJt2Od5RwuY8iFltoWtGfAXW13pW2oAO/lwA/gcWfkmTToIPcOr9osK6j zQiWcAaWm8eqCV1DrKJkXM+qPi6yBSuSkXZpVwl+Oc6+HUQvsrXwDC7SGFAruYjvEKS2 cKQtThZLVNcmGqqN4kiEdN/KLwAdZBh4ql8kIwj8dFly0i2wtj6xj7D5BhVxGRhP6R6a WifOyuiVU1kPTu9vXgmBxm7laI7Y1Mjg7eBkbVT94AmTS4U1o0QUXfNIhbgcJWsSBS7m ku0VLeohbB6YUeu6f2xdrlV7GnRB5Vz6hYz2tjwHi9dMVViBXgmnEm5Aw73RONVaPaqQ If8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zs0Jw7YW; 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 k24-20020ae9f118000000b0078bdcce050bsi8378619qkg.147.2024.04.03.05.14.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:14:18 -0700 (PDT) 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=zs0Jw7YW; 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 5F044384476F for ; Wed, 3 Apr 2024 12:14:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id D1F7D38460B2 for ; Wed, 3 Apr 2024 12:12:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1F7D38460B2 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 D1F7D38460B2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146331; cv=none; b=KKbvVREGFkmjf8vP6GP5p46aJMZ433XKZjZuSKCHtkdbCO1+zUaiOZA5Z+itJabD/F1L8PlLAXHrvEbwtUV7AW1Q6SbfRONwLFft5KftEvgIbVFIj9JFj2VZi5MbZ5NwXxARj1yK+9AZ5Ib/pleVWhN9yH8VQv5/L2vS/X4/IHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146331; c=relaxed/simple; bh=18KWDqJOCvFGiKrMSa8OpXnOZjyCtOADkaYgH7zX9vo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Mz2f2ZU6EIIDBo01OiwzgS02xIux7t9sh4H7haEjj2c7+KRrB6y6h04P7kwFy1e18gBvHmgSlNps/4grM7+U1gGJNPM6p+jI0nOeJbyFRkDDZLkilwap9dVSjR/I3RaVlm74lbfBSom8JQD3xrz48W65bHA070hvDsvfdQBBg1U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5cddc5455aeso3976930a12.1 for ; Wed, 03 Apr 2024 05:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146326; x=1712751126; 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=zlY9goMk06RobzKIAKJy3vjK/nrrQAIbI2heyFcTgXM=; b=zs0Jw7YWBa/RBCvgKVlhi0sOzbB0Egw9UKgRVBch4kZaiX1iFOR70RaXmKXTL1d3Ux lUXU5P+vg7GYTXL0eekq7BhuuSgQEwIjCwaN9B9Q4WSPPXuJ7bjkWoY7GsCGhzC+dtB6 KIPAsRU90/RGwPCE7P+wYqg17cZQOIu5M3IWerExQ2Rcu2FhAZir2zFKiVn+qTjcjaLR PQxfSwIPyX3UeXgg19SAHHOS1dK9LK7CtwD8P+7I6mqdJZbyfKf6mAj3DYmbEiOl/W1X /RLe2l4QK7H3j0r9Sv7HfmniNV+ClK55/7JS+VHvkIgfx6apLhvt35+AjYPJQJwWOMtz fSGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146326; x=1712751126; 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=zlY9goMk06RobzKIAKJy3vjK/nrrQAIbI2heyFcTgXM=; b=s2c9iHwShECbCXdCCyEs4vVmN4LfSCyN09g9ekCIPpUnv4/xOTR6Uo59LS+nhD4ho4 QbGGiJK4tCQNPNtNAFP7iv4p1n551eyCX36+9p4kX/ZeLOrlXdGb2jvg4knT3qWeGfID VGM0GL8O4LDa4VJNFFABumOtwKTf3KYjrQob3bFlYL0Jxh9DbzpTAQ1C5bqn2WX2M8Z2 JRji+cumg08gVVcl2JYoFsdvo5kT6jHn5GHKNx5C4A2kJyq7T6n9oY1zaUvXsBrqOfil chL7PkFh+cv9ox0SAZCfelaTCJaKGui7/Hwv3dGHNk7cw5K7m+mSGam6AI4zZol6szO0 MT7A== X-Gm-Message-State: AOJu0YzAVEiKBosBcFal8GMoD24uzkLIlnYY+nl20+gAg0dPkfn3WEui 851riuqvVr0IxPdAqe21Q0OKC7ON0l0llpQ6oHCe6j1hFs5ccHz6dIUbLcUhkpIf4isXut8Ggpi f X-Received: by 2002:a17:90b:3b88:b0:2a2:2eee:e86e with SMTP id pc8-20020a17090b3b8800b002a22eeee86emr7991046pjb.2.1712146326424; Wed, 03 Apr 2024 05:12:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:05 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 07/10] x86: Do not raise inexact exception on truncl Date: Wed, 3 Apr 2024 09:11:47 -0300 Message-Id: <20240403121150.1018799-8-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. --- .../fpu/s_truncl.S => x86/fpu/s_truncl.c} | 40 +++++++++---------- sysdeps/x86_64/fpu/s_truncl.S | 36 ----------------- 2 files changed, 19 insertions(+), 57 deletions(-) rename sysdeps/{i386/fpu/s_truncl.S => x86/fpu/s_truncl.c} (61%) delete mode 100644 sysdeps/x86_64/fpu/s_truncl.S diff --git a/sysdeps/i386/fpu/s_truncl.S b/sysdeps/x86/fpu/s_truncl.c similarity index 61% rename from sysdeps/i386/fpu/s_truncl.S rename to sysdeps/x86/fpu/s_truncl.c index dfd0ca4a57..59614cd006 100644 --- a/sysdeps/i386/fpu/s_truncl.S +++ b/sysdeps/x86/fpu/s_truncl.c @@ -1,5 +1,5 @@ -/* Truncate long double value. - Copyright (C) 1997-2024 Free Software Foundation, Inc. +/* Round to integer, toward zero. 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 @@ -16,25 +16,23 @@ License along with the GNU C Library; if not, see . */ +#define NO_MATH_REDIRECT +#include +#include #include -#include -ENTRY(__truncl) - fldt 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__truncl) +long double +__truncl (long double x) +{ + fenv_t fenv; + long double r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + 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 (__trunc, trunc) diff --git a/sysdeps/x86_64/fpu/s_truncl.S b/sysdeps/x86_64/fpu/s_truncl.S deleted file mode 100644 index e3d64a84e8..0000000000 --- a/sysdeps/x86_64/fpu/s_truncl.S +++ /dev/null @@ -1,36 +0,0 @@ -/* Truncate long double value. - Copyright (C) 1997-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 - . */ - -#include -#include - -ENTRY(__truncl) - fldt 8(%rsp) - fnstenv -28(%rsp) - movl $0xc00, %edx - orl -28(%rsp), %edx - movl %edx, -32(%rsp) - fldcw -32(%rsp) - frndint - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - fldenv -28(%rsp) - ret -END(__truncl) -libm_alias_ldouble (__trunc, trunc)