From patchwork Mon May 14 22:11:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135763 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp190134lji; Mon, 14 May 2018 15:17:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoK9JXkRIubu2AuagjUuwNHe4uWyy2vsex286LOkbyTLCJNnKVhWAGWbX6gPoM01qzIfSpB X-Received: by 2002:a37:4708:: with SMTP id u8-v6mr10140740qka.299.1526336265468; Mon, 14 May 2018 15:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336265; cv=none; d=google.com; s=arc-20160816; b=qIrjZLAOF6r4wKNyLGzvGeFkUl2Cao3LvfpvOPbMWfeTtjtbExhnjeM3NCGgHLOubP O6hbwaI3YWSz36QiL/X6frDZ3w1CruxB50LtkFxZSJbtT3B+YfIQpZrlvRDKw5pNNDxp ZL3x8myOadFCgZyARHtnkvxMKXiQFX9I6LAotItf+dKWSR9239PDTv16SEwz2SWp+MY3 MDYTu5vYT1KCSuoiYi7MRY8mVAD4mKaeYQDR3YWq20EW2cAJybmY7lOsGW1qoE6QjiIb UzpfSgKLBoCpyNzGn+e28WkPkFgI+xaTksQksKXSQ4zxib6lcMnvKNrpog9NEgbBrvQR jlTg== 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=sMFvxehNW2WjX/2qTbv+EhzKGZ6dKWsMD6UmFGMjN8k=; b=pn/gFj+jUlsV+XDC3/etMuvz9ebwOwshdHN4Dkf6V++xiaiFSjrOwXOfQSbziA8x3K MruvoXrJuZ/Mc0VVjssNmf6JCC4AOun8oS7JHUapuzgKI4JoAUTSLXju5p9bK/Ruzdgf mxc4cbBgUCA6kWw9z3DqidCZnZZ9qsIbusuJiS8Hfy07yyc9v6pHsNTZuUhmqYVyV8PX r8ERFZVN7kWsh9gSWNfriffFAToozV0ZEc+4NCSxfNXW4t6VI1sJ28qOdytDAP0J3C8T +lN+KEmgm/jwS+5NSQwipXoAB+vywRAbN8vgqejaUGW/gQJb7EQZxYKtxPkUqiLO7NOb wEGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Xw4oWvHS; 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 19-v6si6541288qts.53.2018.05.14.15.17.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:17:45 -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=Xw4oWvHS; 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]:49904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILmq-0003sb-R6 for patch@linaro.org; Mon, 14 May 2018 18:17:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILho-0007rT-JT for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhn-0007Vn-Ja for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:32 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:42494) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhn-0007Ug-DX for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:31 -0400 Received: by mail-pl0-x244.google.com with SMTP id u6-v6so8148774pls.9 for ; Mon, 14 May 2018 15:12:31 -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=sMFvxehNW2WjX/2qTbv+EhzKGZ6dKWsMD6UmFGMjN8k=; b=Xw4oWvHSUvr/S9d3lFMZDuiXtbPqogZB9Fn0mY4PYEoNT3ytPLUBUdA7GMw6MNwSne 1pZ68NXADgioiUqmScfeT5fzxiiBlCO4riEE6lJpUiVv2bwG3z3yWc/GytLdOYn1P774 +npjrGV3nbZJ7Q8AdUZF7nwjpoUAY0/QOD0BY= 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=sMFvxehNW2WjX/2qTbv+EhzKGZ6dKWsMD6UmFGMjN8k=; b=RZEBFj80ur4yjCrg4TUAtEeE3UjuXjFKmGNFH4XTRm8ANxIVWSy4Ru6ezRVQ4UtoPt mhsqKIp9LVsxuD6ouVLd8ICwEbINmDnduQklifU/bamIyTnHMmahKPfOMO9y7NOw0THY 12oz2plDrNJscBjsNutxQplrBFduOX8Gk4jWzdYwa8oMMthSf1r5fOq6zXuIYYDfrxvt 82EywN3Ut2vLWM0X0cEpaSnYNosNQT5GxoSR+bUDWfSt3exr4Cl6nN/UIaAahmnPkVGl LLSK0VvZcknAyCARY+MuzThqXXUvqBgq5U8/fwyOcSu1UaqOTkbbEZdTzK24wzlq8M+6 waHw== X-Gm-Message-State: ALKqPwf/fAdVhcpwjNJVH2YMyZPQ+xVpLoAqDnk4SFP1aOaQvK+wDcP2 gWiIUHyqvMe9QEc9AyLmXn/HpN4ncqg= X-Received: by 2002:a17:902:10c:: with SMTP id 12-v6mr11712846plb.252.1526335950252; Mon, 14 May 2018 15:12:30 -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 y2-v6sm14512457pgp.92.2018.05.14.15.12.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:57 -0700 Message-Id: <20180514221219.7091-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-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:c01::244 Subject: [Qemu-devel] [PATCH v5 06/28] 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" Reviewed-by: Peter Maydell 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: Alex Bennée 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 607c4a78d5..19f40d6932 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)) {