From patchwork Sat May 12 00:42:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135597 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1571017lji; Fri, 11 May 2018 17:53:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpU8+/icMoxKCpLDJE2XWWfYOqbLXVNYcPx19aySSuVPlvmu29BaPH47MWd2MChFHyTyc+d X-Received: by 2002:a37:d15c:: with SMTP id s89-v6mr270977qki.132.1526086407421; Fri, 11 May 2018 17:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526086407; cv=none; d=google.com; s=arc-20160816; b=B0uWO1PN4mIauKpuWA1D0AT/ztgLUGuHf2nEYCmg+JkFQgEm4Inzrd7uZkjaTjT/fh NA+9yBSPYAr8pSKR7uQU/L9Zj3+haCHEu5HQNP/qi7LPQH3NjrDYN61MjVo0i9Ja85TZ oCnL9UO9r/I9DmMqlONhEBwivvPCburjBaSksck9JST2Zlvtwl+IiTWzAULgmAczhi/X BgoigmdABt5Qy7pGYNC6bonxJUoDJJegi+Ly+mlxmssr5Okwf9R0knmXg1j+m7nCs0wp YuaWcgJWaTvw54uPimrwsmJACDVCMoIPF2Av8idkZ2nCWggbCawbIbChbl1jVWVp9mYT +bkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=rvlR+Ql7MEYt3TgPxBAN9LiqLt4J1geWtV6fjJYwD6Q=; b=KABHGXhJwZp2aZJwUpFBqOW3FdSs7p0ThjnW82uEpwJoSoT+IwNhnLwvWQwDyTZYVs KHje+moTB1/2be4wpsa8YPUyUx51je1usd5HJ/BBg88uxAnQ12u0/o3cRUrirlck1vPJ 1rtWUNHbG09ctGf6AR47d5AmK7bsZ31n6sL8dVqO6ICTuqmLc89XHU9KDZgf7+vdXBE4 x4FrrQVT5Vo8N9h9taEH5Hbk/9KbIqpz4SyjrrRChJX4NUdvu3nwa4xb32TjekBbKtDx S/Ao6bX0QSIKtZBoN/4SoETBI50L0xBTYsAVYirJ3y6pKaZi1pMCSrFolkxtNt77zk6m lNqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KNOHSlTo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y9-v6si1010538qtb.265.2018.05.11.17.53.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 11 May 2018 17:53:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KNOHSlTo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHIms-0001wb-Rl for patch@linaro.org; Fri, 11 May 2018 20:53:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHIdC-0004KD-PY for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHIdC-0002rI-2U for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:26 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:34144) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fHIdB-0002r3-St for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:25 -0400 Received: by mail-pf0-x241.google.com with SMTP id a14-v6so3439047pfi.1 for ; Fri, 11 May 2018 17:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rvlR+Ql7MEYt3TgPxBAN9LiqLt4J1geWtV6fjJYwD6Q=; b=KNOHSlTopgRlGGJHx6hnSFJqeOScZ3ACjo8nZj7wys5Rf+sEtHTBgvVI5ztv6eVqxR 1BJYCksnWYSwnw+VMVTLyMpsCtGHSRblPw1c/WKPCw0OhM45gxr/3cKvGR8eff6N18YO X0U+Zfc33vK9yRwkgEU7crljzLMWwkmDmHxxc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rvlR+Ql7MEYt3TgPxBAN9LiqLt4J1geWtV6fjJYwD6Q=; b=qPSE8C4XFBwbfp/zD1dbTDqzmGIomrHTxHhZTef6qSRdf05759U40ETM/9mQtrueIQ /M31V87GnH2Fb2AIxnxQRdhl4zIcJM+W2496+xAYqILblL8qS3If1e5KvXhsOffOL7G3 YKmo/UdCMhFYFfg4TcwOJMUggsKSPLHakgZv2PPCG/fi/fDZ274zsZzCYQd1jEUGBt07 P02DQCzxYbo5VqDRRlMArKOv9irwL47n3AyaO1w9sMQe6YBlUQcV+p0NdX0fl6TukRLH 6xWoR5J3r+mu+XSNaN8XPMJF5r74RXPy2HWFZKtT8MjP/N2gYVcb/woIX9EGS09sQbI0 GGHQ== X-Gm-Message-State: ALKqPwc6yeD04yUK0bRHC1xfcCqN49ixpTQ7ZCPw8Y1GbROLtFOSfu2Z DWl1vj09wHdh/xySrsgODXY3jD94MxA= X-Received: by 2002:a62:e710:: with SMTP id s16-v6mr957455pfh.227.1526085804614; Fri, 11 May 2018 17:43:24 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id k84-v6sm10756406pfh.93.2018.05.11.17.43.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 17:43:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 11 May 2018 17:42:51 -0700 Message-Id: <20180512004311.9299-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180512004311.9299-1-richard.henderson@linaro.org> References: <20180512004311.9299-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 07/27] fpu/softfloat: Introduce parts_is_snan_frac X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 15 +++++++++++++++ fpu/softfloat.c | 12 ++---------- 2 files changed, 17 insertions(+), 10 deletions(-) -- 2.17.0 Reviewed-by: Peter Maydell diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 4fc9ea4ac0..515cb12cfa 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -86,6 +86,21 @@ this code that are retained. #define NO_SIGNALING_NANS 1 #endif +/*---------------------------------------------------------------------------- +| For the deconstructed floating-point with fraction FRAC, return true +| if the fraction represents a signalling NaN; otherwise false. +*----------------------------------------------------------------------------*/ + +static bool parts_is_snan_frac(uint64_t frac, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + return false; +#else + flag msb = extract64(frac, DECOMPOSED_BINARY_POINT - 1, 1); + return msb == status->snan_bit_is_one; +#endif +} + /*---------------------------------------------------------------------------- | The pattern for a default generated half-precision NaN. *----------------------------------------------------------------------------*/ diff --git a/fpu/softfloat.c b/fpu/softfloat.c index a56d3d975b..cb68f2eb20 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -331,16 +331,8 @@ static FloatParts canonicalize(FloatParts part, const FloatFmt *parm, part.cls = float_class_inf; } else { part.frac <<= parm->frac_shift; -#ifdef NO_SIGNALING_NANS - part.cls = float_class_qnan; -#else - int64_t msb = part.frac << 2; - if ((msb < 0) == status->snan_bit_is_one) { - part.cls = float_class_snan; - } else { - part.cls = float_class_qnan; - } -#endif + part.cls = (parts_is_snan_frac(part.frac, status) + ? float_class_snan : float_class_qnan); } } else if (part.exp == 0) { if (likely(part.frac == 0)) {