From patchwork Wed Dec 23 11:55:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41531 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 1D8833892010; Wed, 23 Dec 2020 11:56:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D8833892010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608724584; bh=0kQs1LzYzLcTlb2gD2iNHwYuS/grwf+pQayX3Y/OthY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=xII+FvREWLTNQ45jkCyWeigBeHCva0mMBkaXDhetAHX/TrhbBLf9VXSDtWvzMUGRC khqAnG5xM8d65vbjgHaCArXMUlBXV5LuuY1HKGN8YgusaQcOmg/aqR5Ba5La/vx85O gOwOEUtWItxMOxJNM0lqtH+/2o4rf7AQ10bO//64= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by sourceware.org (Postfix) with ESMTPS id 9DA85389041A for ; Wed, 23 Dec 2020 11:56:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9DA85389041A X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id D0F6D48277A; Wed, 23 Dec 2020 11:56:19 +0000 (UTC) Received: from pdx1-sub0-mail-a1.g.dreamhost.com (100-100-138-63.trex.outbound.svc.cluster.local [100.100.138.63]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 5F5F1482749; Wed, 23 Dec 2020 11:56:19 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a1.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.11); Wed, 23 Dec 2020 11:56:19 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Dime-Industry: 765402556cd7b020_1608724579651_270547507 X-MC-Loop-Signature: 1608724579651:3389277851 X-MC-Ingress-Time: 1608724579650 Received: from pdx1-sub0-mail-a1.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTP id 263187F0A4; Wed, 23 Dec 2020 03:56:19 -0800 (PST) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTPSA id 032527F0A0; Wed, 23 Dec 2020 03:56:15 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a1 To: libc-alpha@sourceware.org Subject: [PATCH v2 1/5] x86 long double: Support pseudo numbers in fpclassifyl Date: Wed, 23 Dec 2020 17:25:58 +0530 Message-Id: <20201223115602.3472627-2-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223115602.3472627-1-siddhesh@sourceware.org> References: <20201223115602.3472627-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com, joseph@codesourcery.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Also move sysdeps/i386/fpu/s_fpclassifyl.c to sysdeps/x86/fpu/s_fpclassifyl.c and remove sysdeps/x86_64/fpu/s_fpclassifyl.c Reviewed-by: Adhemerval Zanella --- sysdeps/{i386 => x86}/fpu/s_fpclassifyl.c | 4 ++++ sysdeps/x86_64/fpu/s_fpclassifyl.c | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) rename sysdeps/{i386 => x86}/fpu/s_fpclassifyl.c (87%) delete mode 100644 sysdeps/x86_64/fpu/s_fpclassifyl.c diff --git a/sysdeps/i386/fpu/s_fpclassifyl.c b/sysdeps/x86/fpu/s_fpclassifyl.c similarity index 87% rename from sysdeps/i386/fpu/s_fpclassifyl.c rename to sysdeps/x86/fpu/s_fpclassifyl.c index 501312f51e..a48b7685c4 100644 --- a/sysdeps/i386/fpu/s_fpclassifyl.c +++ b/sysdeps/x86/fpu/s_fpclassifyl.c @@ -34,6 +34,10 @@ __fpclassifyl (long double x) retval = FP_ZERO; else if (ex == 0 && (hx & 0x80000000) == 0) retval = FP_SUBNORMAL; + /* Pseudo-normals, i.e. pseudo-zero, pseudo-infinity and un-normals. They + behave like NaNs, so categorize them as such. */ + else if ((hx & 0x80000000) == 0) + retval = FP_NAN; else if (ex == 0x7fff) retval = ((hx & 0x7fffffff) | lx) != 0 ? FP_NAN : FP_INFINITE; diff --git a/sysdeps/x86_64/fpu/s_fpclassifyl.c b/sysdeps/x86_64/fpu/s_fpclassifyl.c deleted file mode 100644 index 856854b0f5..0000000000 --- a/sysdeps/x86_64/fpu/s_fpclassifyl.c +++ /dev/null @@ -1,2 +0,0 @@ -#include - From patchwork Wed Dec 23 11:55:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41532 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 22BA13892016; Wed, 23 Dec 2020 11:56:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22BA13892016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608724587; bh=wwy+WA8Bj0nQdh2ZQRE34SCL09UdT5pxfU0hTkvjVCw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jsQKxlUkcU/2DQVn48XuQzhQL0nF674aIVwrcPaOEy3DyhVhVyIvdskY8K7KPe+rE riDtFYxx4CyMVzWECc2i25xNeEiDAkjBBMfsAy4dmEtMzB95ssRiVgue2zoGJbxHmy Y9wtYWLEPeRZFfQm+zOnZr/umAvfswY+qlS5Dn7k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bumble.birch.relay.mailchannels.net (bumble.birch.relay.mailchannels.net [23.83.209.25]) by sourceware.org (Postfix) with ESMTPS id 1CDF4389200F for ; Wed, 23 Dec 2020 11:56:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1CDF4389200F X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E799F321A56; Wed, 23 Dec 2020 11:56:22 +0000 (UTC) Received: from pdx1-sub0-mail-a1.g.dreamhost.com (100-96-27-97.trex.outbound.svc.cluster.local [100.96.27.97]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 5269A320EF2; Wed, 23 Dec 2020 11:56:22 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a1.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.11); Wed, 23 Dec 2020 11:56:22 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Sponge-Shrill: 3f86320929059ea2_1608724582581_694987250 X-MC-Loop-Signature: 1608724582581:2562893189 X-MC-Ingress-Time: 1608724582581 Received: from pdx1-sub0-mail-a1.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTP id 17EF07F0A7; Wed, 23 Dec 2020 03:56:22 -0800 (PST) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTPSA id 115997F0A4; Wed, 23 Dec 2020 03:56:19 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a1 To: libc-alpha@sourceware.org Subject: [PATCH v2 2/5] x86 long double: Support pseudo numbers in isnanl Date: Wed, 23 Dec 2020 17:25:59 +0530 Message-Id: <20201223115602.3472627-3-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223115602.3472627-1-siddhesh@sourceware.org> References: <20201223115602.3472627-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com, joseph@codesourcery.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This syncs up isnanl behaviour with gcc. Also move the isnanl implementation to sysdeps/x86 and remove the sysdeps/x86_64 version. Reviewed-by: Adhemerval Zanella --- sysdeps/{i386 => x86}/fpu/s_isnanl.c | 12 +++++++----- sysdeps/x86_64/fpu/s_isnanl.c | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) rename sysdeps/{i386 => x86}/fpu/s_isnanl.c (76%) delete mode 100644 sysdeps/x86_64/fpu/s_isnanl.c diff --git a/sysdeps/i386/fpu/s_isnanl.c b/sysdeps/x86/fpu/s_isnanl.c similarity index 76% rename from sysdeps/i386/fpu/s_isnanl.c rename to sysdeps/x86/fpu/s_isnanl.c index fb97317bc9..45541df08a 100644 --- a/sysdeps/i386/fpu/s_isnanl.c +++ b/sysdeps/x86/fpu/s_isnanl.c @@ -28,16 +28,18 @@ static char rcsid[] = "$NetBSD: $"; int __isnanl(long double x) { - int32_t se,hx,lx; + int32_t se,hx,lx,pn; GET_LDOUBLE_WORDS(se,hx,lx,x); se = (se & 0x7fff) << 1; - /* The additional & 0x7fffffff is required because Intel's - extended format has the normally implicit 1 explicit - present. Sigh! */ + /* Detect pseudo-normal numbers, i.e. exponent is non-zero and the top + bit of the significand is not set. */ + pn = (uint32_t)((~hx & 0x80000000) & (se|(-se)))>>31; + /* Clear the significand bit when computing mantissa. */ lx |= hx & 0x7fffffff; se |= (uint32_t)(lx|(-lx))>>31; se = 0xfffe - se; - return (int)((uint32_t)(se))>>16; + + return (int)(((uint32_t)(se)) >> 16) | pn; } hidden_def (__isnanl) weak_alias (__isnanl, isnanl) diff --git a/sysdeps/x86_64/fpu/s_isnanl.c b/sysdeps/x86_64/fpu/s_isnanl.c deleted file mode 100644 index 06e69c3aeb..0000000000 --- a/sysdeps/x86_64/fpu/s_isnanl.c +++ /dev/null @@ -1 +0,0 @@ -#include From patchwork Wed Dec 23 11:56:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41533 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 A8139389201D; Wed, 23 Dec 2020 11:56:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8139389201D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608724590; bh=pBjUPtAv4HxgPiI5Sok39wHxIpJH/zR90qllXto9bSg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=YU9KEri6Jd0R1iGj0JCWPS9bdY0ehKUHkx1BIdLTS0veMyys/wpsCIbks17i9JhzU Hf6LY7WCuIIFPr18ccXx/pUlB2CwDWxgn49filRHd29O3Z7ocLF5sKhtT+o3Oze2V8 HMM8k48yPsXzZrHTeI0BZqXnkPjhq3fgFqnq9pCs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from donkey.elm.relay.mailchannels.net (donkey.elm.relay.mailchannels.net [23.83.212.49]) by sourceware.org (Postfix) with ESMTPS id 7B58B389201A for ; Wed, 23 Dec 2020 11:56:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7B58B389201A X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 1D51F321973; Wed, 23 Dec 2020 11:56:26 +0000 (UTC) Received: from pdx1-sub0-mail-a1.g.dreamhost.com (100-105-161-17.trex.outbound.svc.cluster.local [100.105.161.17]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 8B7783218F0; Wed, 23 Dec 2020 11:56:25 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a1.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.11); Wed, 23 Dec 2020 11:56:26 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Suffer-Obese: 566168023aca5d39_1608724585835_2940522322 X-MC-Loop-Signature: 1608724585835:3445465596 X-MC-Ingress-Time: 1608724585834 Received: from pdx1-sub0-mail-a1.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTP id 4E2907F0A4; Wed, 23 Dec 2020 03:56:25 -0800 (PST) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTPSA id E8A137F0A6; Wed, 23 Dec 2020 03:56:22 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a1 To: libc-alpha@sourceware.org Subject: [PATCH v2 3/5] Partially revert 681900d29683722b1cb0a8e565a0585846ec5a61 Date: Wed, 23 Dec 2020 17:26:00 +0530 Message-Id: <20201223115602.3472627-4-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223115602.3472627-1-siddhesh@sourceware.org> References: <20201223115602.3472627-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_NUMSUBJECT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com, joseph@codesourcery.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Do not attempt to fix the significand top bit in long double input received in printf. The code should never reach here because isnan should now detect unnormals as NaN. This is already a NOP for glibc since it uses the gcc __builtin_isnan, which detects unnormals as NaN. --- sysdeps/x86/ldbl2mpn.c | 8 -------- sysdeps/x86/tst-ldbl-nonnormal-printf.c | 5 +---- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/sysdeps/x86/ldbl2mpn.c b/sysdeps/x86/ldbl2mpn.c index 23afedfb67..ec8464eef7 100644 --- a/sysdeps/x86/ldbl2mpn.c +++ b/sysdeps/x86/ldbl2mpn.c @@ -115,14 +115,6 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, && res_ptr[N - 1] == 0) /* Pseudo zero. */ *expt = 0; - else - /* Unlike other floating point formats, the most significant bit - is explicit and expected to be set for normal numbers. Set it - in case it is cleared in the input. Otherwise, callers will - not be able to produce the expected multi-precision integer - layout by shifting. */ - res_ptr[N - 1] |= (mp_limb_t) 1 << (LDBL_MANT_DIG - 1 - - ((N - 1) * BITS_PER_MP_LIMB)); return N; } diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c index 54381ece0b..2b513960a7 100644 --- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c +++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c @@ -42,10 +42,7 @@ do_test (void) char buf[30]; int ret = snprintf (buf, sizeof (buf), "%Lg", value); TEST_COMPARE (ret, strlen (buf)); - if (strcmp (buf, "nan") != 0) - /* If snprintf does not recognize the non-normal number as a NaN, - it has added the missing explicit MSB. */ - TEST_COMPARE_STRING (buf, "3.02201e-4624"); + TEST_COMPARE_STRING (buf, "nan"); return 0; } From patchwork Wed Dec 23 11:56:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41534 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 384613892020; Wed, 23 Dec 2020 11:56:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 384613892020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608724596; bh=LSlWsDzgwILNS1hptG2aobGqYSY6VF1J/JN3ZiFARnc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Q/2oFWVG95RsYPIomJFZkMcKyvykd6nZ6pOFZ7J0d8DFNHVpsKeSUO7JMNk7DKqQ5 5HN+TYXKcNcgTGASG6lsDjK+hUubj8fIbjD7eKj+Nm+XIGsSYWBp3xG7Wk8cla069R IfPRjNbVbRi0xCWKmiIB+HFK1akiYw01CYAtfOd0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hamster.birch.relay.mailchannels.net (hamster.birch.relay.mailchannels.net [23.83.209.80]) by sourceware.org (Postfix) with ESMTPS id 1C4A1389201A for ; Wed, 23 Dec 2020 11:56:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1C4A1389201A X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 2F4461E17B7; Wed, 23 Dec 2020 11:56:32 +0000 (UTC) Received: from pdx1-sub0-mail-a1.g.dreamhost.com (100-96-1-8.trex.outbound.svc.cluster.local [100.96.1.8]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B76181E189B; Wed, 23 Dec 2020 11:56:29 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a1.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.11); Wed, 23 Dec 2020 11:56:32 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Wipe-Arithmetic: 0578d1af58ddb4b5_1608724591850_3184251114 X-MC-Loop-Signature: 1608724591850:3571170041 X-MC-Ingress-Time: 1608724591850 Received: from pdx1-sub0-mail-a1.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTP id 65B7B7F0A4; Wed, 23 Dec 2020 03:56:29 -0800 (PST) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTPSA id 1FA1D7F0A6; Wed, 23 Dec 2020 03:56:25 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a1 To: libc-alpha@sourceware.org Subject: [PATCH v2 4/5] x86 long double: Consider pseudo numbers as signaling Date: Wed, 23 Dec 2020 17:26:01 +0530 Message-Id: <20201223115602.3472627-5-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223115602.3472627-1-siddhesh@sourceware.org> References: <20201223115602.3472627-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com, joseph@codesourcery.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Add support to treat pseudo-numbers specially and implement x86 version to consider all of them as signaling. --- sysdeps/generic/nan-pseudo-number.h | 27 ++++++++++++++++++++ sysdeps/ieee754/ldbl-96/s_issignalingl.c | 7 +++++- sysdeps/x86/fpu/nan-pseudo-number.h | 32 ++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 sysdeps/generic/nan-pseudo-number.h create mode 100644 sysdeps/x86/fpu/nan-pseudo-number.h diff --git a/sysdeps/generic/nan-pseudo-number.h b/sysdeps/generic/nan-pseudo-number.h new file mode 100644 index 0000000000..ce1176a208 --- /dev/null +++ b/sysdeps/generic/nan-pseudo-number.h @@ -0,0 +1,27 @@ +/* Pseudo-normal number handling. Generic version. + Copyright (C) 2020 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 + . */ + +#ifndef NAN_PSEUDO_NUMBER_H +#define NAN_PSEUDO_NUMBER_H 1 + +/* Define this macro to 1 and provide an definition for IS_PSEUDO_SIGNALING if + pseudo-normal numbers need special handling. */ +#define HANDLE_PSEUDO_NUMBERS 0 +#define IS_PSEUDO_SIGNALING(x) 0 + +#endif /* nan-pseudo-number.h */ diff --git a/sysdeps/ieee754/ldbl-96/s_issignalingl.c b/sysdeps/ieee754/ldbl-96/s_issignalingl.c index ec542ad468..fff6a85932 100644 --- a/sysdeps/ieee754/ldbl-96/s_issignalingl.c +++ b/sysdeps/ieee754/ldbl-96/s_issignalingl.c @@ -19,12 +19,14 @@ #include #include #include +#include int __issignalingl (long double x) { uint32_t exi, hxi, lxi; GET_LDOUBLE_WORDS (exi, hxi, lxi, x); + int ret = 0; #if HIGH_ORDER_BIT_IS_SET_FOR_SNAN # error not implemented #else @@ -36,9 +38,12 @@ __issignalingl (long double x) hxi |= (lxi | -lxi) >> 31; /* We do not recognize a pseudo NaN as sNaN; they're invalid on 80387 and later. */ +#if HANDLE_PSEUDO_NUMBERS + ret = IS_PSEUDO_SIGNALING(x); +#endif /* We have to compare for greater (instead of greater or equal), because x's significand being all-zero designates infinity not NaN. */ - return ((exi & 0x7fff) == 0x7fff) && (hxi > 0xc0000000); + return ret || (((exi & 0x7fff) == 0x7fff) && (hxi > 0xc0000000)); #endif } libm_hidden_def (__issignalingl) diff --git a/sysdeps/x86/fpu/nan-pseudo-number.h b/sysdeps/x86/fpu/nan-pseudo-number.h new file mode 100644 index 0000000000..9cc37a3eee --- /dev/null +++ b/sysdeps/x86/fpu/nan-pseudo-number.h @@ -0,0 +1,32 @@ +/* Pseudo-normal number handling. x86 version. + Copyright (C) 2020 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 + . */ + +#ifndef NAN_PSEUDO_NUMBER_H +#define NAN_PSEUDO_NUMBER_H 1 + +#define HANDLE_PSEUDO_NUMBERS 1 +/* A pseudo-normal number (that is not pseudo-denormal) has a non-zero exponent + and the MSB of significand is clear. All pseudo-normal numbers are deemed + signaling. */ +#define IS_PSEUDO_SIGNALING(x) ({ \ + uint32_t exi, hxi, lxi __attribute__ ((unused)); \ + GET_LDOUBLE_WORDS (exi, hxi, lxi, x); \ + ((exi & 0x7fff) && ((hxi & 0x80000000) == 0)); \ +}) + +#endif /* nan-pseudo-number.h */ From patchwork Wed Dec 23 11:56:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41535 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 BAC4F3892024; Wed, 23 Dec 2020 11:56:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BAC4F3892024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608724597; bh=t8oCTFvV1HgrMG1OUglmYQlPFljMlNBQM2WNOCFEQJw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=tMWv8OL1daDHpqZFrqX4KK4IPMdO12Csv7WSJT+vAkroePOIQveFIN2QizC+cC2dl CiS1koAeorh+aKy6Fr6/raNDAaV/sedbI23cLCY/fg3znDR08eCBeCRfhnnU+o+BJd 86qNZoRnhtRa3/iqpz/r7avSaG9TOM/ICTqUniuA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from olivedrab.birch.relay.mailchannels.net (olivedrab.birch.relay.mailchannels.net [23.83.209.135]) by sourceware.org (Postfix) with ESMTPS id 63ADA3892015 for ; Wed, 23 Dec 2020 11:56:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 63ADA3892015 X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 66FE01E1F07; Wed, 23 Dec 2020 11:56:33 +0000 (UTC) Received: from pdx1-sub0-mail-a1.g.dreamhost.com (100-100-138-63.trex.outbound.svc.cluster.local [100.100.138.63]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id DB7C21E1A6C; Wed, 23 Dec 2020 11:56:32 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a1.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.11); Wed, 23 Dec 2020 11:56:33 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Rock-Snatch: 646d6fb704ecc995_1608724593175_3944238564 X-MC-Loop-Signature: 1608724593175:1167196700 X-MC-Ingress-Time: 1608724593174 Received: from pdx1-sub0-mail-a1.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTP id A69AA7F0A6; Wed, 23 Dec 2020 03:56:32 -0800 (PST) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a1.g.dreamhost.com (Postfix) with ESMTPSA id 6747A7F0A0; Wed, 23 Dec 2020 03:56:29 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a1 To: libc-alpha@sourceware.org Subject: [PATCH v2 5/5] x86 long double: Add tests for pseudo normal numbers Date: Wed, 23 Dec 2020 17:26:02 +0530 Message-Id: <20201223115602.3472627-6-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223115602.3472627-1-siddhesh@sourceware.org> References: <20201223115602.3472627-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com, joseph@codesourcery.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Add some tests for fpclassify, isnanl, isinfl and issignaling. --- sysdeps/x86/fpu/Makefile | 3 +- sysdeps/x86/fpu/test-unnormal.c | 132 ++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 sysdeps/x86/fpu/test-unnormal.c diff --git a/sysdeps/x86/fpu/Makefile b/sysdeps/x86/fpu/Makefile index 600e42c3db..e77de56d14 100644 --- a/sysdeps/x86/fpu/Makefile +++ b/sysdeps/x86/fpu/Makefile @@ -4,11 +4,12 @@ CPPFLAGS += -I../soft-fp libm-support += powl_helper tests += test-fenv-sse test-fenv-clear-sse test-fenv-x87 test-fenv-sse-2 \ - test-flt-eval-method-387 test-flt-eval-method-sse + test-flt-eval-method-387 test-flt-eval-method-sse test-unnormal CFLAGS-test-fenv-sse.c += -msse2 -mfpmath=sse CFLAGS-test-fenv-clear-sse.c += -msse2 -mfpmath=sse CFLAGS-test-fenv-sse-2.c += -msse2 -mfpmath=sse CFLAGS-test-flt-eval-method-387.c += -fexcess-precision=standard -mfpmath=387 CFLAGS-test-flt-eval-method-sse.c += -fexcess-precision=standard -msse2 \ -mfpmath=sse +CFLAGS-test-unnormal.c += -fsignaling-nans -std=c2x endif diff --git a/sysdeps/x86/fpu/test-unnormal.c b/sysdeps/x86/fpu/test-unnormal.c new file mode 100644 index 0000000000..a6baa01802 --- /dev/null +++ b/sysdeps/x86/fpu/test-unnormal.c @@ -0,0 +1,132 @@ +/* Test long double classification with x86 pseudo normal numbers. + Copyright (C) 2020 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 +#include +#include +#include +#include + +/* If we need to add regular NaNs here then we need another member specifying + whether the NaN is signaling and then issignaling test should be updated to + use it. Additionally, all pseudo-numbers should be classified as + signaling. */ +struct tests +{ + ieee_long_double_shape_type d; + int class; +} inputs[] = { + /* Normal. */ + { + .d.parts.lsw = 0x00000400, + .d.parts.msw = 0x00000000, + .d.parts.sign_exponent = 0x0400, + .class = FP_NAN + }, + { + .d.parts.lsw = 0x00000400, + .d.parts.msw = 0xf0000000, + .d.parts.sign_exponent = 0x0400, + .class = FP_NORMAL + }, + /* Pseudo-infinite. */ + { + .d.parts.lsw = 0x00000000, + .d.parts.msw = 0x00000000, + .d.parts.sign_exponent = 0x7fff, + .class = FP_NAN + }, + { + .d.parts.lsw = 0x00000000, + .d.parts.msw = 0x80000000, + .d.parts.sign_exponent = 0x7fff, + .class = FP_INFINITE + }, + /* Pseudo-zero. */ + { + .d.parts.lsw = 0x00000000, + .d.parts.msw = 0x00000000, + .d.parts.sign_exponent = 0x0100, + .class = FP_NAN + }, + { + .d.parts.lsw = 0x00000000, + .d.parts.msw = 0x00000000, + .d.parts.sign_exponent = 0x0000, + .class = FP_ZERO + }, +}; + +typedef void (*testfunc_t) (long double, int); + +static int +test_func (const char *testname, testfunc_t testfunc) +{ + verbose_printf ("* %s:\n", testname); + + for (int i = 0; i < sizeof (inputs)/sizeof (struct tests); i++) + { + verbose_printf ("Testing 0x%04x %08x %08x\n", + inputs[i].d.parts.sign_exponent, inputs[i].d.parts.msw, + inputs[i].d.parts.lsw); + testfunc (inputs[i].d.value, inputs[i].class); + } + + return 0; +} + +static void +test_fpclassify (long double value, int class) +{ + TEST_COMPARE (fpclassify (value), class); +} + +static void +test_isinf (long double value, int class) +{ + TEST_COMPARE ((isinf (value) != 0), (class == FP_INFINITE)); +} + +static void +test_isnan (long double value, int class) +{ + TEST_COMPARE ((isnan (value) != 0), (class == FP_NAN)); +} + +static void +test_issignaling (long double value, int class) +{ + TEST_COMPARE ((issignaling (value) != 0), (class == FP_NAN)); +} + +int +do_test (void) +{ + int ret = 0; + + test_func ("fpclassify", test_fpclassify); + test_func ("isinf", test_isinf); + test_func ("isnan", test_isnan); + test_func ("issignaling", test_issignaling); + + return ret; +} + +#include