From patchwork Tue Dec 15 14:13:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41394 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 A9E0E386EC25; Tue, 15 Dec 2020 14:14:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9E0E386EC25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608041653; bh=jncrFSjUCUrJ40mK/imvqn/jDhK6+0NsvxYuW7n3EYw=; 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=lCFiTc2GqAU8dvrXlTewMq5O0g5kJ+sCgQoaaKbaFSMOYsCetwxR7YPAhfCJ3+Oxr ZJofU5DePkVxyIW6pCa9fETSWk5lGBJibtGGgOaU3/7Jz+akd78jY0pXUetRSWv/hp Y2+GIfm9YNPBLe/3LmMs/pXciieTmcQXebObEqBc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dog.elm.relay.mailchannels.net (dog.elm.relay.mailchannels.net [23.83.212.48]) by sourceware.org (Postfix) with ESMTPS id B3B413861038 for ; Tue, 15 Dec 2020 14:14:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B3B413861038 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 520F7362F96; Tue, 15 Dec 2020 14:14:07 +0000 (UTC) Received: from pdx1-sub0-mail-a35.g.dreamhost.com (100-96-8-104.trex.outbound.svc.cluster.local [100.96.8.104]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 9558F361A4F; Tue, 15 Dec 2020 14:14:05 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a35.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); Tue, 15 Dec 2020 14:14:07 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Stretch-Name: 411034a14758664f_1608041646784_1352486080 X-MC-Loop-Signature: 1608041646784:635306170 X-MC-Ingress-Time: 1608041646784 Received: from pdx1-sub0-mail-a35.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a35.g.dreamhost.com (Postfix) with ESMTP id 5D9117F5FF; Tue, 15 Dec 2020 06:14:05 -0800 (PST) Received: from rhbox.redhat.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-a35.g.dreamhost.com (Postfix) with ESMTPSA id 0FCF67E63B; Tue, 15 Dec 2020 06:14:01 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a35 To: libc-alpha@sourceware.org Subject: [PATCH 1/5] x86 long double: Support pseudo numbers in fpclassifyl Date: Tue, 15 Dec 2020 19:43:35 +0530 Message-Id: <20201215141339.2684384-2-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201215141339.2684384-1-siddhesh@sourceware.org> References: <20201215141339.2684384-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.8 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" --- sysdeps/i386/fpu/s_fpclassifyl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sysdeps/i386/fpu/s_fpclassifyl.c b/sysdeps/i386/fpu/s_fpclassifyl.c index 501312f51e..aeaec7279c 100644 --- a/sysdeps/i386/fpu/s_fpclassifyl.c +++ b/sysdeps/i386/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 unnormals. 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; From patchwork Tue Dec 15 14:13:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41399 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 4A7E4386EC6E; Tue, 15 Dec 2020 14:19:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A7E4386EC6E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608041967; bh=2RTxUl0f9KlytahP2/lNy0PBCLyjSREZN+HmiRWmOn8=; 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=aayI/AAeHpP/TF6oUVeFC60Z/J3dhaaGzg+EGx7VPih22Kj4jGvJgtHgmz8Oy8uIq sfwrqmJtOjTpw+ldkfGoYEZBFnSX6UK5NnII4If/4lPEJ4JDRvrId4HrAhcgFjOY6/ fcNH+OXZYpxPkeKyPl4/Xo30mAexqKbB+5TOkqhc= 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 219CA384B00F for ; Tue, 15 Dec 2020 14:19:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 219CA384B00F 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 08CEF922C0A; Tue, 15 Dec 2020 14:14:10 +0000 (UTC) Received: from pdx1-sub0-mail-a35.g.dreamhost.com (100-98-64-116.trex.outbound.svc.cluster.local [100.98.64.116]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3C392922B7C; Tue, 15 Dec 2020 14:14:09 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a35.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); Tue, 15 Dec 2020 14:14:09 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Share-Invention: 30848bd16d4079fc_1608041649520_1875342607 X-MC-Loop-Signature: 1608041649520:1230610148 X-MC-Ingress-Time: 1608041649520 Received: from pdx1-sub0-mail-a35.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a35.g.dreamhost.com (Postfix) with ESMTP id F01C97E63B; Tue, 15 Dec 2020 06:14:08 -0800 (PST) Received: from rhbox.redhat.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-a35.g.dreamhost.com (Postfix) with ESMTPSA id 246E67E357; Tue, 15 Dec 2020 06:14:05 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a35 To: libc-alpha@sourceware.org Subject: [PATCH 2/5] x86 long double: Support pseudo numbers in isnanl Date: Tue, 15 Dec 2020 19:43:36 +0530 Message-Id: <20201215141339.2684384-3-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201215141339.2684384-1-siddhesh@sourceware.org> References: <20201215141339.2684384-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 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_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" Sync up with gcc behaviour. This change splits out the core isnanl logic so that it can be reused. --- sysdeps/i386/fpu/s_isnanl.c | 10 ++-------- sysdeps/x86/fpu/isnanl_common.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 sysdeps/x86/fpu/isnanl_common.h diff --git a/sysdeps/i386/fpu/s_isnanl.c b/sysdeps/i386/fpu/s_isnanl.c index fb97317bc9..6824f31d96 100644 --- a/sysdeps/i386/fpu/s_isnanl.c +++ b/sysdeps/i386/fpu/s_isnanl.c @@ -25,19 +25,13 @@ static char rcsid[] = "$NetBSD: $"; #include #include +#include "sysdeps/x86/fpu/isnanl_common.h" int __isnanl(long double x) { int32_t se,hx,lx; 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! */ - lx |= hx & 0x7fffffff; - se |= (uint32_t)(lx|(-lx))>>31; - se = 0xfffe - se; - return (int)((uint32_t)(se))>>16; + return x86_isnanl (se, hx, lx); } hidden_def (__isnanl) weak_alias (__isnanl, isnanl) diff --git a/sysdeps/x86/fpu/isnanl_common.h b/sysdeps/x86/fpu/isnanl_common.h new file mode 100644 index 0000000000..60a4af5b41 --- /dev/null +++ b/sysdeps/x86/fpu/isnanl_common.h @@ -0,0 +1,32 @@ +/* Common inline isnanl implementation for x86. + 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 + . */ + +static inline __always_inline int +x86_isnanl (int32_t se, int32_t hx, int32_t lx) +{ + se = (se & 0x7fff) << 1; + /* Detect pseudo-normal numbers, i.e. exponent is non-zero and the top + bit of the significand is not set. */ + int 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) | pn; +} From patchwork Tue Dec 15 14:13:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41395 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 3EC58386EC3A; Tue, 15 Dec 2020 14:14:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3EC58386EC3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608041657; bh=PZukCgxQci5nN1lLLCQpHh84TjrU4YuwtaikI0VDwiw=; 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=dPBD8/y6kwj/UB3j+mr2lw/T3HVfvxvHEUjnJ8lTHeIfZQNysusrJvhtHi+1kwZrt Z7aX4Wxy8krtkFoTDquo/Gl6+jFTQv66fbrJJ4s68prjewK192Ah12WKAUwMXL9oaD OZfY2Y4RTkgQeop1eABwcYwuMS08S180e/2ajywk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bird.elm.relay.mailchannels.net (bird.elm.relay.mailchannels.net [23.83.212.17]) by sourceware.org (Postfix) with ESMTPS id BCCD1386EC3A for ; Tue, 15 Dec 2020 14:14:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BCCD1386EC3A 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 18253341C30; Tue, 15 Dec 2020 14:14:13 +0000 (UTC) Received: from pdx1-sub0-mail-a35.g.dreamhost.com (100-96-12-130.trex.outbound.svc.cluster.local [100.96.12.130]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 5CBCD341AB4; Tue, 15 Dec 2020 14:14:12 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a35.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); Tue, 15 Dec 2020 14:14:13 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Abiding-Tank: 508f09b831911985_1608041652622_1660292938 X-MC-Loop-Signature: 1608041652622:1385650132 X-MC-Ingress-Time: 1608041652622 Received: from pdx1-sub0-mail-a35.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a35.g.dreamhost.com (Postfix) with ESMTP id D0A477E63B; Tue, 15 Dec 2020 06:14:11 -0800 (PST) Received: from rhbox.redhat.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-a35.g.dreamhost.com (Postfix) with ESMTPSA id BE0547F4E0; Tue, 15 Dec 2020 06:14:09 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a35 To: libc-alpha@sourceware.org Subject: [PATCH 3/5] Partially revert 681900d29683722b1cb0a8e565a0585846ec5a61 Date: Tue, 15 Dec 2020 19:43:37 +0530 Message-Id: <20201215141339.2684384-4-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201215141339.2684384-1-siddhesh@sourceware.org> References: <20201215141339.2684384-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.5 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 -------- 1 file changed, 8 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; } From patchwork Tue Dec 15 14:13:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41396 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 C9709386EC55; Tue, 15 Dec 2020 14:14:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9709386EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608041659; bh=lY9vcZi83BdsYLNdefReifjq9975KYkEbE+J4C6DjN4=; 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=K1mlQ8xHrTgTjp6HNs/6tS6QwofkjBBAHM+NnmzIQhZPfriHYqIZu+dnK2dhfcvpZ Sz2dgk8s3N6/gs5hCObVQ8rrbMVn58kpv4ZauC81JsbnyZmJgYMm8z0AsSDuRqRIXe XGgAMHc9wHT/NSzp6Yt/8NELX3jriDNjoNzdLg6Y= 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 8F9F6386EC4F for ; Tue, 15 Dec 2020 14:14:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8F9F6386EC4F 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 00D51122A6A; Tue, 15 Dec 2020 14:14:15 +0000 (UTC) Received: from pdx1-sub0-mail-a35.g.dreamhost.com (100-96-87-21.trex.outbound.svc.cluster.local [100.96.87.21]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 81F56122FFB; Tue, 15 Dec 2020 14:14:14 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a35.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); Tue, 15 Dec 2020 14:14:14 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Little-Harmony: 600dd64b09ac053e_1608041654785_3829548252 X-MC-Loop-Signature: 1608041654785:891526289 X-MC-Ingress-Time: 1608041654785 Received: from pdx1-sub0-mail-a35.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a35.g.dreamhost.com (Postfix) with ESMTP id 36E887E63B; Tue, 15 Dec 2020 06:14:14 -0800 (PST) Received: from rhbox.redhat.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-a35.g.dreamhost.com (Postfix) with ESMTPSA id 65EF87F4E0; Tue, 15 Dec 2020 06:14:12 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a35 To: libc-alpha@sourceware.org Subject: [PATCH 4/5] x86 long double: Consider pseudo numbers as signaling Date: Tue, 15 Dec 2020 19:43:38 +0530 Message-Id: <20201215141339.2684384-5-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201215141339.2684384-1-siddhesh@sourceware.org> References: <20201215141339.2684384-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.8 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_H3, RCVD_IN_MSPIKE_WL, 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" Implement a separate x86 version of issignalingl that returns true for pseudo-normal numbers. Also drop comment from the generic version of s_issignalingl since it is no longer true or relevant. --- sysdeps/ieee754/ldbl-96/s_issignalingl.c | 2 -- sysdeps/x86/fpu/s_issignalingl.c | 39 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 sysdeps/x86/fpu/s_issignalingl.c diff --git a/sysdeps/ieee754/ldbl-96/s_issignalingl.c b/sysdeps/ieee754/ldbl-96/s_issignalingl.c index ec542ad468..2aa0ffae0e 100644 --- a/sysdeps/ieee754/ldbl-96/s_issignalingl.c +++ b/sysdeps/ieee754/ldbl-96/s_issignalingl.c @@ -34,8 +34,6 @@ __issignalingl (long double x) hxi ^= 0x40000000; /* If lxi != 0, then set any suitable bit of the significand in hxi. */ hxi |= (lxi | -lxi) >> 31; - /* We do not recognize a pseudo NaN as sNaN; they're invalid on 80387 and - later. */ /* 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); diff --git a/sysdeps/x86/fpu/s_issignalingl.c b/sysdeps/x86/fpu/s_issignalingl.c new file mode 100644 index 0000000000..df273b881d --- /dev/null +++ b/sysdeps/x86/fpu/s_issignalingl.c @@ -0,0 +1,39 @@ +/* Test for signaling NaN - 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 + . */ + +#include +#include +#include +#include "sysdeps/x86/fpu/isnanl_common.h" + +int +__issignalingl (long double x) +{ + uint32_t exi, hxi, lxi, nan, pn; + GET_LDOUBLE_WORDS (exi, hxi, lxi, x); +#if HIGH_ORDER_BIT_IS_SET_FOR_SNAN +# error not implemented +#else + nan = x86_isnanl (exi, hxi, lxi); + pn = (~hxi & 0x80000000) >> 31; + hxi = (~hxi & 0x40000000) >> 30; + + return nan & (pn | hxi); +#endif +} +libm_hidden_def (__issignalingl) From patchwork Tue Dec 15 14:13:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 41397 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 5EA72386EC4F; Tue, 15 Dec 2020 14:14:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EA72386EC4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608041665; bh=bgTXLQQ9UtZu5a53G/bXzF8TQ/337oHM3I145NQVToE=; 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=jORYhW+dn2V8mWt1PQPkXmnMy2VkgIEfsODMF3KHcQduI9lV+oXfpvm8CJXMXgPgF GosuDSxRHhyugotJaRuKL42QxgZNveC3e+X/bmojmBArbiZo/8g9BdMWwtqFWtMaJ7 NnjcDcU7yNU3PsxqdYVFXg3Y1y1HNLrSWjmY8+O8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from cyan.elm.relay.mailchannels.net (cyan.elm.relay.mailchannels.net [23.83.212.47]) by sourceware.org (Postfix) with ESMTPS id 96FAE384B00F for ; Tue, 15 Dec 2020 14:14:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 96FAE384B00F 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 F2FD71223A2; Tue, 15 Dec 2020 14:14:17 +0000 (UTC) Received: from pdx1-sub0-mail-a35.g.dreamhost.com (100-96-87-21.trex.outbound.svc.cluster.local [100.96.87.21]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id E4A03122EAE; Tue, 15 Dec 2020 14:14:16 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a35.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); Tue, 15 Dec 2020 14:14:17 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Interest-Plucky: 53f284dc0ed2e890_1608041657284_3010144328 X-MC-Loop-Signature: 1608041657284:974736753 X-MC-Ingress-Time: 1608041657284 Received: from pdx1-sub0-mail-a35.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a35.g.dreamhost.com (Postfix) with ESMTP id 9BA797E63B; Tue, 15 Dec 2020 06:14:16 -0800 (PST) Received: from rhbox.redhat.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-a35.g.dreamhost.com (Postfix) with ESMTPSA id C2DCD7E357; Tue, 15 Dec 2020 06:14:14 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a35 To: libc-alpha@sourceware.org Subject: [PATCH 5/5] x86 long double: Add tests for pseudo normal numbers Date: Tue, 15 Dec 2020 19:43:39 +0530 Message-Id: <20201215141339.2684384-6-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201215141339.2684384-1-siddhesh@sourceware.org> References: <20201215141339.2684384-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 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_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" Add some tests for fpclassify, isnanl, isinfl and issignaling. --- sysdeps/x86/fpu/Makefile | 3 +- sysdeps/x86/fpu/test-unnormal.c | 196 ++++++++++++++++++++++++++++++++ 2 files changed, 198 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..fc65d9290f --- /dev/null +++ b/sysdeps/x86/fpu/test-unnormal.c @@ -0,0 +1,196 @@ +/* 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 + +struct tests +{ + const char *val; + int class; +} inputs[] = { + /* Normal. */ + {"\x00\x04\x00\x00\x00\x00\x00\x00\x00\x04", FP_NAN}, + {"\x00\x04\x00\x00\x00\x00\x00\xf0\x00\x04", FP_NORMAL}, + /* Pseudo-infinite. */ + {"\x00\x00\x00\x00\x00\x00\x00\x00\xff\x7f", FP_NAN}, + {"\x00\x00\x00\x00\x00\x00\x00\x80\xff\x7f", FP_INFINITE}, + /* Pseudo-zero. */ + {"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", FP_NAN}, + {"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", FP_ZERO}, +}; + +const char *classes[5]; +#define stringify(N) #N + +static void +initialize (void) +{ + classes[FP_NAN] = stringify(FP_NAN); + classes[FP_INFINITE] = stringify(FP_INFINITY); + classes[FP_ZERO] = stringify(FP_ZERO); + classes[FP_SUBNORMAL] = stringify(FP_SUBNORMAL); + classes[FP_NORMAL] = stringify(FP_NORMAL); +} + +static void +unnormal_str (const char *val, char *ret) +{ + for (int i = 9; i >= 0; i--) + { + if (i == 7 || i == 3) + *ret++ = ' '; + snprintf(ret, 3, "%02x", (unsigned char) val[i]); + ret += 2; + } +} + +static int +test_fpclassify (void) +{ + int ret = 0; + + printf ("* fpclassify tests:\n"); + for (int i = 0; i < sizeof (inputs)/sizeof (struct tests); i++) + { + long double value; + char buf[22]; + + memcpy (&value, inputs[i].val, 10); + unnormal_str(inputs[i].val, buf); + int class = fpclassify(value); + + if (class != inputs[i].class) + { + printf ("0x%s: got %s, expected %s\n", buf, + classes[fpclassify(value)], + classes[inputs[i].class]); + ret |= 1; + } + else + printf ("0x%s: OK\n", buf); + } + return ret; +} + +static int +test_isinf (void) +{ + int ret = 0; + + printf ("* isinfl tests:\n"); + for (int i = 0; i < sizeof (inputs)/sizeof (struct tests); i++) + { + long double value; + char buf[22]; + + memcpy (&value, inputs[i].val, 10); + unnormal_str(inputs[i].val, buf); + int inf = isinf (value); + + if ((inputs[i].class == FP_INFINITE && inf) + || (inputs[i].class != FP_INFINITE && !inf)) + printf ("0x%s: OK\n", buf); + else + { + printf ("0x%s: got %s, expected %s\n", buf, + inf ? "INFINITE" : "NOT INFINITE", + classes[inputs[i].class]); + ret |= 1; + } + } + + return ret; +} + +static int +test_isnan (void) +{ + int ret = 0; + + printf ("* isnanl tests:\n"); + for (int i = 0; i < sizeof (inputs)/sizeof (struct tests); i++) + { + long double value; + char buf[22]; + + memcpy (&value, inputs[i].val, 10); + unnormal_str(inputs[i].val, buf); + int nan = isnan (value); + + if ((inputs[i].class == FP_NAN && nan) + || (inputs[i].class != FP_NAN && !nan)) + printf ("0x%s: OK\n", buf); + else + { + printf ("0x%s: got %s, expected %s\n", buf, + nan ? "NAN" : "NOT NAN", + classes[inputs[i].class]); + ret |= 1; + } + } + return ret; +} + +static int +test_issignaling (void) +{ + int ret = 0; + + printf ("* issignaling tests:\n"); + for (int i = 0; i < sizeof (inputs)/sizeof (struct tests); i++) + { + long double value; + char buf[22]; + + memcpy (&value, inputs[i].val, 10); + unnormal_str(inputs[i].val, buf); + int signaling = issignaling (value); + + if ((inputs[i].class == FP_NAN && signaling) + || (inputs[i].class != FP_NAN && !signaling)) + printf ("0x%s: OK\n", buf); + else + { + printf ("0x%s: got %s, expected %s\n", buf, + signaling ? "SIGNALING" : "NOT SIGNALING", + classes[inputs[i].class]); + ret |= 1; + } + } + return ret; +} + +int +do_test (void) +{ + int ret = 0; + + initialize (); + + ret |= test_fpclassify (); + ret |= test_isinf (); + ret |= test_isnan (); + ret |= test_issignaling (); + + return ret; +} + +#include