From patchwork Thu Dec 28 17:20:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758604 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4115552wrw; Thu, 28 Dec 2023 09:23:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4RWFx+VqLqNkHMYVIV1oFCPS7WtkU9cDolPdD1oZefUxI7Qbi6GKSicC1Y7ZzHXyYPGrd X-Received: by 2002:a05:6214:2aab:b0:67f:6982:ed93 with SMTP id js11-20020a0562142aab00b0067f6982ed93mr15301592qvb.60.1703784196546; Thu, 28 Dec 2023 09:23:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784196; cv=pass; d=google.com; s=arc-20160816; b=y32WyCeAk0ZzykFecF7FpjwC3OG7eQnN3KA1Iw1FvkBRuKHT//t+ZhSDNQIGNbY2LI BQamttKvhDnj6pecPv9gtfpAvFXIF11xDo2uxsms9LNLcQdzaSKcTTAGckVU4xe/BOAS P8eV62GawvEXrWpiQQXfUbO9ourO2rksSB165Hjmz6QvxFK/Cx3OCW6q4amqJhPxtfxk k5YUJQslVi/lEjw6MXLPz9Tt2ApqknD1hdFkE+lh+jnqqvF6tT4lnx4LMj2LFV1WFbHJ cCwLFHmwryvqOzjMEno5WY6ppz6DM/MbC3HTUbsbxjE0D1vwvQo4wBEWcg1GrMPbkcYl jwlw== 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=w/9PHEFPptWXcVnPOvZucTuCoSC877hTCncf9odbS5g=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=wTHydT5MExobNxmRHvyOgAq3PzQ4KOvmhv4lqW7ZwWXpscBTcP2yNOkUee/uGS6d2z s9n6bchsLOjG0tfgwabBBGgxqjxyP6wEayowZDHLZFUc/gC8QlAoqr8H7VxdV0R253Oe z1XhxL78gUu1P+HBEhuzHzjJJHxGOVTwyIFAYg8J6MV6oyLPZjShnw63n7wg0d0IVWtb zQPUrpsTSyqMbRDGRKKlDoYOup3HJusy4C1OdnerP5xd02zpDOo/GeEQOXJW+2+mLz/Z voRRwB8ga5aX8l9aUdEba1qzVCSifltRo42hoywyp3AH+5sypQ1QKlBBPK+7OMK2z7A/ gOUA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LBhBwTNj; 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 a9-20020a0ce389000000b0067f982ddf03si13978706qvl.509.2023.12.28.09.23.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:23:16 -0800 (PST) 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=LBhBwTNj; 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 2393938582A6 for ; Thu, 28 Dec 2023 17:23:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 5C9973858002 for ; Thu, 28 Dec 2023 17:20:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C9973858002 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 5C9973858002 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784054; cv=none; b=x+srz2HO+ijxljjJWIg9wEAZpUEyVy2g+F0YR13s8sqPxJTyz02BsUgkjrZj9K+ee4RaWyUOCBI4PTdzb8DLEAh+Uw2tTISrUBljxeLV+1t6uDo0nPxqrjW22RMET6DRtZVCn9HrM1irr8J7di2K8y9MfILRqCmFO8nSj0QRjl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784054; c=relaxed/simple; bh=D1yDmR5qcLzfU4mCnflNeZnmm0PZuf08hTKF6ZZ10IM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GxTqAiNm6UwtRLI05xnTLAkq1R9kqm3bD59TEE6LgaZOYUK4/+oYP9z699/dHFfWjYLw1e6To0iAgcZxPCaLOTW+AF9D1E6zSVMxXP37/in00hGCHKeWO+Aqj0tJsell62Q1bc8bESUvTBEtRLgzMTuzCHjJXMNFWCuFGh+J7YU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6d099d316a8so5751034b3a.0 for ; Thu, 28 Dec 2023 09:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784050; x=1704388850; 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=w/9PHEFPptWXcVnPOvZucTuCoSC877hTCncf9odbS5g=; b=LBhBwTNjWVb4e+UW3nRpwPUQnWmInQ6B1ITIm4AUxlw6jfaRM55vhVCVTXAnizGj00 NKlFckWiZqL2jDG6maKE164b9SrsUaluas7ohB4iuQ/NzZYkKnthOtEnbycC8oBBph55 2WJUWlNR085ljNuSU+BgQo7UZjvWv+qKDC45VIje0T+J8epsX/M1CMwYgh5BFUSfaKCS kEY3M8l5YPmx/5fULJuMjrOiFzRdnZN/KnXU4XGl/D9VOTyWXS7N/HcVFm8JYX5LlRYq G1J0CzsqPHweGp/AsuRjYogGGGiorqIdl5fysJC7Lq6sReHMDS47oOJbhigq5QLIaG/X PpCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784050; x=1704388850; 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=w/9PHEFPptWXcVnPOvZucTuCoSC877hTCncf9odbS5g=; b=fLIDCgR/CCzXizrNptN7zXPhywGYcNzUvd33SY0cw9qRVIvvVQw70sJUdOmG8wIavC ZatNFxLAZId7x1OckqeQFEekH4Xb64EjN9GK5I19FGn1gvkUjOJWbdvDKkA/+3fff0rW dbBOBcDXBwp4Ta9uPbOkODz5O4YlBP32VaaHt5Dxa87X/aEfnSlzPDUBnCKIaj8br99i 7i+MLOHiD99H8KKdADHZKuEVkftcOEtjdggQppxi2K2Z5vWapsny0PnurJD3q6NoJjDL NxiUtuHFmJyPNz6UTGxFg78U4cqefRAea0ktxqY3cEpgsn/3LWXlYA5lx9rFzsqu7fvU enfA== X-Gm-Message-State: AOJu0YzMpDwnYiE0THw1ZDhMeNJ/usSMgsj4QIZT0kHrPF4MWTff7UK6 w6Yo6m8vetp0j6kczJyNSvh1uo4W8Xy+9Tjss1O7XvYznUo= X-Received: by 2002:a05:6a20:8825:b0:195:bda4:4b2d with SMTP id c37-20020a056a20882500b00195bda44b2dmr4972533pzf.102.1703784049819; Thu, 28 Dec 2023 09:20:49 -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.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:49 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 12/12] i386: Do not raise inexact exception on trunc/truncf Date: Thu, 28 Dec 2023 14:20:26 -0300 Message-Id: <20231228172026.2013007-13-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.7 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. --- sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} | 37 +++++++++++---------- sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} | 37 +++++++++++---------- 2 files changed, 38 insertions(+), 36 deletions(-) rename sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} (61%) rename sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} (61%) diff --git a/sysdeps/i386/fpu/s_trunc.S b/sysdeps/i386/fpu/s_trunc.c similarity index 61% rename from sysdeps/i386/fpu/s_trunc.S rename to sysdeps/i386/fpu/s_trunc.c index 145288bc8e..b071ad9750 100644 --- a/sysdeps/i386/fpu/s_trunc.S +++ b/sysdeps/i386/fpu/s_trunc.c @@ -1,5 +1,5 @@ -/* Truncate double value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. +/* Round to integer, toward zero. i386 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,22 +16,23 @@ License along with the GNU C Library; if not, see . */ -#include +#define NO_MATH_REDIRECT +#include +#include #include -ENTRY(__trunc) - fldl 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 - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__trunc) +double +__trunc (double x) +{ + fenv_t fenv; + 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_double (__trunc, trunc) diff --git a/sysdeps/i386/fpu/s_truncf.S b/sysdeps/i386/fpu/s_truncf.c similarity index 61% rename from sysdeps/i386/fpu/s_truncf.S rename to sysdeps/i386/fpu/s_truncf.c index 7bdf0e5111..86d46ff660 100644 --- a/sysdeps/i386/fpu/s_truncf.S +++ b/sysdeps/i386/fpu/s_truncf.c @@ -1,5 +1,5 @@ -/* Truncate float value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. +/* Round to integer, toward zero. i386 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,22 +16,23 @@ License along with the GNU C Library; if not, see . */ -#include +#define NO_MATH_REDIRECT +#include +#include #include -ENTRY(__truncf) - flds 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 - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__truncf) +float +__truncf (float x) +{ + fenv_t fenv; + float 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_float (__trunc, trunc)