From patchwork Thu Dec 28 17:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758607 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4115681wrw; Thu, 28 Dec 2023 09:23:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbCMvEZfrMbFbr2rtxKY9SloDYKismDRgavMaQzDfdyYBZyNw8fKTYZIbOhrlToQyW1hI4 X-Received: by 2002:a05:6214:62a:b0:67f:9eb:f1ec with SMTP id a10-20020a056214062a00b0067f09ebf1ecmr16696179qvx.56.1703784211816; Thu, 28 Dec 2023 09:23:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784211; cv=pass; d=google.com; s=arc-20160816; b=QV1Aqo2+F4c2C9ZN6Nhxphsa+D3V1DdCC130JmPGxXHz00mm+96zXZqoIvXZFuujAy u0AVgjTCBQjpY+vv1i8skylfzrv5e4RXwpi6pLVbcwV0Kbql2YGc7vL1dU0au3emuEsf iP6kZRv01xksH1bACeB0NMPXrQv1YEedQ9Le7IXFRAjhGvvRmUmulkCM4FChupiY6S1L HgKW5EuRHnV+3SztbYHqrkZs7pBW8RlFZFcbnIOJskMo1WwU6L9yzfQcb68zfwwt63Jq mwrKISG6yYKe31eq1hfwlMwflGetxYs8pjDhPef+urLJQcfD+w8+AUJ+2SNBpZm8qiPy 6/Og== 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:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=fPFbCo5zJQ/DhKLz/wo4gqZYgwvZ1TiNCDqnPQy/l+Q=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=YwdmQU/mDHpWP8gzSeynN7VziWnxultpAlSc/g6X/wKSUBYcSWXYzCTovHRB8vXdKx UR+mH5Nu5FFZvejryVLVzQj34JDephVebrfQRYJ2zb0FjoffkIRrTJgGt6ZVOtcDN4lW 9bUMqEjrwy6COME94xvydzfOt9u8wrkXcUnIE/N8FxvdlDleg9z5QoTTzLxHp9VC/Rf/ WlrYCE2aWNCKd0SOHUd2rvQrUhdpgOY+FkjtKC+B+qOXT6VIr7RuZa+3THuE8+Lzhr0q Q12hm8A2C3pM6BDJOQa+ACKp7D/ZHnUtlpHsvEx2LA/J2VzCcjV2mfJUToYwCfwTSayi OlHQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hfHNu1bz; 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 s15-20020a0ce30f000000b0067f87ec5939si15725364qvl.324.2023.12.28.09.23.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:23:31 -0800 (PST) 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=hfHNu1bz; 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 685F638582A6 for ; Thu, 28 Dec 2023 17:23:31 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id A459D385841A for ; Thu, 28 Dec 2023 17:20:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A459D385841A 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 A459D385841A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; cv=none; b=dZ14rv0TxeNQYJ+twBCvLUwYkc2i/EciN5xnbBS09BGnARE9zZ8YoMU5mLrLigpFWnQkOCFhnbvX2gAx69l6BZCe2T4NhBMy5bWwgBytV0EaQo8rkGXyq4U/66VEaZ+Q51N+/7AYirixYbCahNdQSR8aA3Ck+2v5NA5IdniBLYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; c=relaxed/simple; bh=APmPneg9e9H+Z2LkqQtP3cFsiPjFfGEFus6reP8+IKA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ccKLH68LmlM7qtaZWLngubf2zjcFYwtl4ya4Jqbaw9wOzV4lXIcBZbXo1J1jU0iW98C49k0YfAK/YQ0lpdpCs25jkAyJkZJZaPn0v864aqI36acv44A5ZSIWb2f7xYMXgN1DjYsZQxw7OjfzKhY2FFr87FVTyN3Y0R+6Acj3nsA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6d9cb95ddd1so951728b3a.1 for ; Thu, 28 Dec 2023 09:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784045; x=1704388845; 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=fPFbCo5zJQ/DhKLz/wo4gqZYgwvZ1TiNCDqnPQy/l+Q=; b=hfHNu1bz7HelpE2e1+2/trkP9pTjiksPsmQeKzaXOsvkc7h+tR8tZcs8ObpeC5EOpq 1UGcYHJlYeH7+gYwPGmSPnBhqsDd74FWoGq0jV1Yp4vSmB56qwT7ki2IaeVqWMbUG+Qm p+UwUiS2dgteyKaeJk0JsjHdKyQEk8ErlYYI9APBzxJDk/xwqZnIsyG5SCsv5sYWMXbp 8I0BU/gkaVDuSYxsTARQ3vEtGlMLK/BQUmyRA8eE0iUeqIvUMu9MYIBStTV0/buFdxcB 9ESRGgTwUn+jGLHr3AlGIxN/GMqldpjeI41AxvCzMWqm+fa6znlaEaI9mXQRjL5GegzL qeMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784045; x=1704388845; 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=fPFbCo5zJQ/DhKLz/wo4gqZYgwvZ1TiNCDqnPQy/l+Q=; b=isczxbK2obvy4sclu8lqtgD9pVKxrH4oQwwDmP7luPtphmKZYuuBFOfvXF82+1qLDR hh3cr0zZwhVCdPQ+H6jNmmdfdu/oBKFRkQjgwnlaJSkLqdPKghOuOw6LgBZKFMMVaEtt fYr4OWXucbNv/RaYKn+B2F2rDc4jYf8imDOSqts+Nvq/wFGG1U1ooWGQWVqWAWZxBe+N D0qFcROKdIA3hxn/krCTFgXeLr0d2YxofEv/gM3aMpiS2IJ86+Id/0eugPT5WZeEVdtu 8QKveXKVIij+XYmFso2k+dNAFF5dK8DDNFdpHEJZcREoOlqH1WmBJu2KIkCmKXa283rb nunQ== X-Gm-Message-State: AOJu0YyDpoIgge33Lb5XcgtO3jYIrH2FsRLZxyfB0hTAG5tSBPnBqfed VnIDzcSSIgqr1SlYQcgVY/Ow9bJ/ALUnlZdPwIfXkNy0pFg= X-Received: by 2002:a05:6a00:1d28:b0:6d9:aa4b:3800 with SMTP id a40-20020a056a001d2800b006d9aa4b3800mr4363471pfx.19.1703784045189; Thu, 28 Dec 2023 09:20:45 -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.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:44 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 09/12] x86: Do not raise inexact exception on truncl Date: Thu, 28 Dec 2023 14:20:23 -0300 Message-Id: <20231228172026.2013007-10-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+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 cfd4e75252..249b307004 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-2023 Free Software Foundation, Inc. +/* Round to integer, toward zero. 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 @@ -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 8d319e68b0..0000000000 --- a/sysdeps/x86_64/fpu/s_truncl.S +++ /dev/null @@ -1,36 +0,0 @@ -/* Truncate long double value. - Copyright (C) 1997-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 - . */ - -#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)