From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 39B483846410 for ; Wed, 3 Apr 2024 13:15:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 39B483846410 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 39B483846410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712150134; cv=none; b=kpA3RYodaW/xC0GhzjWnrlupEo9zLsGJGL6R802R0QU06Qk1bvC/RKG0R/7MWhG8/fVxDAbqT2Dqs0DqP0OcaJKPf9y4e4+aNQfZlcAjngZxYHUuGScLotq3yP367kuYPl/jYNgi6MuxGMy8QlIwGLLkmEO2Fww7EA32Vz1tRdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712150134; c=relaxed/simple; bh=P6dwq+p2IS4Oj/EaexMQbBKKpBmBNJb5v2wZn9Oeohc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=rhBdNVu+6gBVUI5GSB9hEcDOj2njzgpFq1vFgLRfhUNE7GpyvkYbZYeS464HKshsQ4hFiUnINeuXknGXOP1LtD2ZAz0bRl38ihPq+pbJ9xG91NhC3HAO8BoUHsotxndEhvKU5awY7uZ11eCfx1IkEungs3/daPIy6Ua5X7lYUAk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ecc9f0bdaaso1185600b3a.1 for ; Wed, 03 Apr 2024 06:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712150130; x=1712754930; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=lZCMu7yEoUiviJsOziuGHeCa+h5WxWDE6v+czszWgDU=; b=kClXySwUVl4gZVy7fm6De9gytdwV9u5dy0nb1K5UIGEBb1sASVVEzT6514nUkNkkxE Mg3uk0usTTzejKz+N2c4NSf2Q4iU9PHMwxe2f7RAp42lO52uZaTUmIZxdRK+Yp8q8Lbs ZKTRJarJpkubuwyAoHMxypRzoIQaMpgkSAKDhtIyzPHXK79dkjEuryfeFgxDwiRlKPz5 MuJ/u8IFueKYo6cNbjpmvEN2h4+zf0GbS9//x9HSaPol+Fmuf8bbYWG8aUzegTJuexCM Bif8hqchNC471QchXBoCi1WuSTUkG9jJIYFOMhKE5cs73a+DWNiCgTkZczP80MpO2CYh BNgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150130; x=1712754930; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lZCMu7yEoUiviJsOziuGHeCa+h5WxWDE6v+czszWgDU=; b=Yps2ai0esrFxojLWpHUUVDhjhGD4YdtNKagN/nU/5tjUGZ6w67ZIQJQFv10Iw+STZm 4zsq/vd3JFFBFTHVE0AvHJy3G9Cwnxws+pzgQAYxrYSY3blnLDNh/8XZQoyekHJNUlJv ASnuolf85INA9kmmA8McqXlWdvAArkZtM2vzsiRinloPfLByJZFxesMYur1aEJCDAm2p hkMRuaIlNfmRvF0xN6yR5cEPONQRtgiwPfLznHykvqq+KSo02UK5YcauKApkm21bOqnf f48THr0zqYfHuYXXKxULrhteQ65gGINs7RN6pPzT41AhEPmsLhd7TRtaG95eu9o7k/9j eONg== X-Gm-Message-State: AOJu0Yw5NlQkIupsSb83h6R7T79r3M6jgcnPD7RAXj3xJqFsD4iUkTM0 s2koRBJcUhWVykkpKszq+xrJKNw7XNVy2OsZbxWMitXQ3qZM1jojDDjAvgHO8wpEKfy5z1HgJqE t X-Google-Smtp-Source: AGHT+IFMmWvIIY0qe3kGAIv3CNCwD1VSub+VDRhijRIGi61rLmm6c8CCoCNXPZQMH7JjnHj7o9PdQQ== X-Received: by 2002:a05:6a00:3a23:b0:6e9:74d7:7092 with SMTP id fj35-20020a056a003a2300b006e974d77092mr18818045pfb.24.1712150129845; Wed, 03 Apr 2024 06:15:29 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c3:b18e:ec2c:788a:1fcc:a268? ([2804:1b3:a7c3:b18e:ec2c:788a:1fcc:a268]) by smtp.gmail.com with ESMTPSA id gx5-20020a056a001e0500b006e729dd12d5sm11650575pfb.48.2024.04.03.06.15.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Apr 2024 06:15:29 -0700 (PDT) Message-ID: <1d165499-67dc-4e1b-8a91-15fb5d3c8646@linaro.org> Date: Wed, 3 Apr 2024 10:15:27 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 05/10] x86: Do not raise inexact exception on ceill To: "H.J. Lu" Cc: libc-alpha@sourceware.org References: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> <20240403121150.1018799-6-adhemerval.zanella@linaro.org> Content-Language: en-US From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 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 List-Id: On 03/04/24 10:04, H.J. Lu wrote: > On Wed, Apr 3, 2024 at 5:12 AM Adhemerval Zanella > wrote: >> >> It is not allowed anymore on ISO C23. >> >> Checked on x86_64-linux-gnu and i686-linux-gnu. >> --- >> sysdeps/i386/fpu/s_ceill.S | 39 ------------------------------------ >> sysdeps/x86/fpu/s_ceill.c | 38 +++++++++++++++++++++++++++++++++++ >> sysdeps/x86_64/fpu/s_ceill.S | 34 ------------------------------- >> 3 files changed, 38 insertions(+), 73 deletions(-) >> delete mode 100644 sysdeps/i386/fpu/s_ceill.S >> create mode 100644 sysdeps/x86/fpu/s_ceill.c >> delete mode 100644 sysdeps/x86_64/fpu/s_ceill.S >> >> diff --git a/sysdeps/i386/fpu/s_ceill.S b/sysdeps/i386/fpu/s_ceill.S >> deleted file mode 100644 >> index a551fce7f9..0000000000 >> --- a/sysdeps/i386/fpu/s_ceill.S >> +++ /dev/null >> @@ -1,39 +0,0 @@ >> -/* >> - * Public domain. >> - */ >> - >> -#include >> -#include >> - >> -RCSID("$NetBSD: $") >> - >> -ENTRY(__ceill) >> - 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 $0x0800,%edx /* round towards +oo */ >> - orl 4(%esp),%edx >> - andl $0xfbff,%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 (__ceill) >> -libm_alias_ldouble (__ceil, ceil) >> diff --git a/sysdeps/x86/fpu/s_ceill.c b/sysdeps/x86/fpu/s_ceill.c >> new file mode 100644 >> index 0000000000..6ccc9d84d4 >> --- /dev/null >> +++ b/sysdeps/x86/fpu/s_ceill.c >> @@ -0,0 +1,38 @@ >> +/* Return smallest 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 >> +__ceill (long double x) >> +{ >> + fenv_t fenv; >> + long double r; >> + >> + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD); >> + 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); >> + > > Since all these newly added functions are almost identical, > should we use a template instead of repeating the similar > code sequence? Something like > > TYPE > FUNC (TYPE x) > { > fenv_t fenv; > TYPE r; > > libc_feholdexcept_setround_387 (&fenv, FE_OPTION); > 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; > > } Sounds reasonable, I will update the patch.