From patchwork Wed Apr 3 12:11:49 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: 785435 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp282989wro; Wed, 3 Apr 2024 05:13:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXYXqoWzCGlKH1HES32mzw7vzDfFaxDxgmkBk+QlbKfP63n42znMl5KGsKgZuJa7Rpasv+q8QVpbGans8pdUbu X-Google-Smtp-Source: AGHT+IHgmCKLme4OVqInF7tNrIlRf8wERFpdIV+VOnUcQFKB4p6vs1JQH6az78zS5x0wiyluNF2A X-Received: by 2002:a05:6830:18eb:b0:6e5:ebf:ed65 with SMTP id d11-20020a05683018eb00b006e50ebfed65mr2536455otf.31.1712146439063; Wed, 03 Apr 2024 05:13:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146439; cv=pass; d=google.com; s=arc-20160816; b=AzShVhBQChiU8IpzIrBVkJpg3spDKZDQqKiZqCWkoT5L/ov0xHmt4taw7uOzr9KySK 0uVHAd9EfHl1zmstztQOpXPmLwdLsJXtVoHmzP2mYNPxxuOkkOZIaMmUAccbK64qJTnS SjaGNTolJu0LGpZMSGNz+P2cFI9NJ+4MbEt22x6Lt0GZHgEfk6r+iJEl1Q7pUMA5gHsX fnaGr1umUNu1UKk1lO4Xgq7zbNkBDFsGABA73XfhzIPRwyf87IqjOuiAjXUJy1ElZ5Z+ fuUGFvLkFx1J4p95HeAOtR/VHECDd31yPG6SxLGc091jQBKHya/lBlmmQIizMnycnuB6 RMxQ== 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=116LvhQoZoYG5EqlPfIh2lOHRaUeY+a+L9AtMyuji3g=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=wRQbzwVwU5ufyZ06Ak88riFExOnxrgSz5OidrKGLpeUzFsYnvdJok077kVFB1isb+T 1QmKQRBsRmdacw8wwdNCuZsjt0BrwQE5fRm1i1lBn89XRDN7CLwyJj53QWufHrimnRvp zzmlcw/mtI9UahTnkI4gDo6r/MrSz38yVgyXz7//X05Zjp3L8H4nHJXH9upq5EONyv0r +zPRnJVvbK8Qo7EsH98BbmTJe069QT6AT625mae465+EV7MvAyjdVYgRaY7G80H1D/Qm WcqJ9X5vflPfCxgCLj4FvYM5a0OCHusfSRgpuzJMi6Pby5LjhN3/k9plhFA5HnjWjCm9 Wi5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=edHk3bwX; 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 ei14-20020ad45a0e000000b006991f0f14d5si3034252qvb.538.2024.04.03.05.13.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:13:59 -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=edHk3bwX; 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 A8C003845BE1 for ; Wed, 3 Apr 2024 12:13:58 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 3D2313847718 for ; Wed, 3 Apr 2024 12:12:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D2313847718 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 3D2313847718 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146333; cv=none; b=fjRoIWLt15/HgBgCQrSjnmdOj8l/Hj19iEi4l3xLDQ7JJScDnquDGhciYqQDVlqgZWn00dHH8oXGlsnwK2uxcuVidfZVxyQn6BQR9kv2iSFZJkFfW8yV0UlfB6YnOpDZ24Kgn/5FZ0IAI1cgijxR4ahBBwNEscxgf82V0n7tTqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146333; c=relaxed/simple; bh=1semKmK8KQYDjaxbDquUACFTy/pOOqvAsAHk9ChhDDY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=yD4WhL3zNZO1ZS1QbeLablVx9gBQWMuESoeomV+jaLYudDDxKg5uZO+e9R6nnamV/Iql69Lqrvpojpe2BgAIXb5NcOhCl/cWVBTBTrQ8f0sFpMd2KhiDBPZpmmuEJSTiN1RZIHArAynTNwUIWFQHsjP4KNrhN1L9rxMN7450L1c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5d8b519e438so4585764a12.1 for ; Wed, 03 Apr 2024 05:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146330; x=1712751130; 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=116LvhQoZoYG5EqlPfIh2lOHRaUeY+a+L9AtMyuji3g=; b=edHk3bwXciUb7Oh6Ia4zDryH4F55wIdToBcUL42Ysk0yv59/Z08vbYs96vecPQUr2n O8v7/lDkOmdR+XPqIy7ZiHXKWw8Tg9rC6UwRkfb5GUW3aSfCEYBpxbGZHeHee+7glcvW S3CuHiBuNQfpD2cycXXjkErJew2BA52HafHcglWxwH24HY4ZN0bDNwzjq2jSwm322Kao bIplGu7C7JQEJ7ta8YJppTMnczAxrE/5BDXFSmWi08gxgkFZhfsyVz6SX0e+nOS2Vd9T /R+JA/VEs76HxcDwcSkvxPVpTEXQP6EahBTFrCxU/oQ0d1BwTzE6k4N4hmHA0uPNYw+h VyJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146330; x=1712751130; 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=116LvhQoZoYG5EqlPfIh2lOHRaUeY+a+L9AtMyuji3g=; b=LF9XyoRohXqkE1hzPixRp6fAi0uRsi1f7QvpFgCFSP4lvTmqthgJxsJEmJIRz7L1xB Wtq2Va+C3gXRV6b3aF8kwemMj81PHPq+71Ycm8BUFXafXkrF2jQZ9wNqDY/uMrapXsNw zv9FSLpjl4oz3nUrcXmCSc8zgDWVj4kTOPdP2y/BMso0B/4XFUlDAta2Ofb84tVtD6vy uyGA223+Z03IijzzfL4wdmB0dbijkuN3I8iKQ4QtUUFKYKBAkBujkpaVZHK2HJ8rvwHC nWN6Oh8FT8VShojdn987yso9ipygojx+AcMiwK18Fv06nprSAYlwjZMBA5SNM7CxPWQu lvfQ== X-Gm-Message-State: AOJu0YzVf7Kcz9uEVfnC8vrKU5YIhyLbpnT6zu1IwzCwGzT5JtM+kVOp k8loeTHaj5VFKE7emvH1sFWxrph+BSEWxNXeavfrNbIozr1aD2AM47qxhIcVtC/JispTeiuSQ/G H X-Received: by 2002:a17:90a:fe90:b0:2a2:9001:94bf with SMTP id co16-20020a17090afe9000b002a2900194bfmr1835928pjb.14.1712146329679; Wed, 03 Apr 2024 05:12:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:09 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 09/10] i386: Do not raise inexact exception on ceil/ceilf Date: Wed, 3 Apr 2024 09:11:49 -0300 Message-Id: <20240403121150.1018799-10-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_ceil.S | 34 ---------------------------------- sysdeps/i386/fpu/s_ceil.c | 38 ++++++++++++++++++++++++++++++++++++++ sysdeps/i386/fpu/s_ceilf.S | 34 ---------------------------------- sysdeps/i386/fpu/s_ceilf.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_ceil.S create mode 100644 sysdeps/i386/fpu/s_ceil.c delete mode 100644 sysdeps/i386/fpu/s_ceilf.S create mode 100644 sysdeps/i386/fpu/s_ceilf.c diff --git a/sysdeps/i386/fpu/s_ceil.S b/sysdeps/i386/fpu/s_ceil.S deleted file mode 100644 index 99984f9b8d..0000000000 --- a/sysdeps/i386/fpu/s_ceil.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_ceil.S,v 1.4 1995/05/08 23:52:13 jtc Exp $") - -ENTRY(__ceil) - fldl 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 */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceil) -libm_alias_double (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceil.c b/sysdeps/i386/fpu/s_ceil.c new file mode 100644 index 0000000000..1ab3d357ba --- /dev/null +++ b/sysdeps/i386/fpu/s_ceil.c @@ -0,0 +1,38 @@ +/* Return smallest integral value not less than argument. i386 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 + +double +__ceil (double x) +{ + fenv_t fenv; + 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); + + return r; +} +libm_alias_double (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceilf.S b/sysdeps/i386/fpu/s_ceilf.S deleted file mode 100644 index 03e8e22609..0000000000 --- a/sysdeps/i386/fpu/s_ceilf.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $") - -ENTRY(__ceilf) - flds 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 */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceilf) -libm_alias_float (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceilf.c b/sysdeps/i386/fpu/s_ceilf.c new file mode 100644 index 0000000000..3de0a962f3 --- /dev/null +++ b/sysdeps/i386/fpu/s_ceilf.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 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 + +float +__ceilf (float x) +{ + fenv_t fenv; + float 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); + + return r; +} +libm_alias_float (__ceil, ceil)