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; +}