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: 87977 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A75D93844026 for ; Wed, 3 Apr 2024 12:14:13 +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-Google-Smtp-Source: AGHT+IHUxeaGLk8RXCdW6vBvQpYhwL0FnxAfTUxIilI4PO8G3HJCueLwJp2G0He3ih6PvM3xYMLY7Q== 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+patchwork=sourceware.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)