From patchwork Wed May 16 15:52:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 136024 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1111986lji; Wed, 16 May 2018 09:04:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo2EjHpAAdr91N3XYrFB/VHhb4yc8Zxygjtx60oQOfhk3q+fYAuiEIj8D5E3yqfvkIrC0GL X-Received: by 2002:a37:91c5:: with SMTP id t188-v6mr1360445qkd.159.1526486650080; Wed, 16 May 2018 09:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526486650; cv=none; d=google.com; s=arc-20160816; b=z7Sa/f0oV4nVtDl6ykS1PuEhskBn+1ekwBBSCse0DmnVFuljjw92eKum4D5r6q6ang 2GUqH9OrW9rwZrc3PayD66azwIUOGQZrlDfmaGTsUcqYvG+ZKpCADhdhFo9s67zS4aPZ rDr4GB+DBQQ1G+Rb63PFQy8YUgR2MwC7vvtNpSWuJCEPGYqTOaULZmRjEZ37OxUzR2GU fkWmMxAgu7jeRmYD7WE4VJLcu1D1mW1BgWMyYiCBtmU3Zb55w8Og969bRaDfszDuVmWc PZj+TUeEz8Sjx43hA/nD1cWSEkW/l09/zixo01+ghUZ0StKqlTjd7DP9MAzOhSH1B0gK PJXA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=LQoF9e5L3ALMayOgvkerESyi2UVKdvRwamrm6aU1hPU=; b=s6cvHg09x7i3wjxrfV45nj1qPoNFjGxGdmO4i74nvgnaIfs9CJm8cYvgPy1MlWtrJ7 U2hwBc0e3rJZUFvZxqPCKkbZQ0LyxocJ+lT38CO1JefHPNJE8+NCp0omS72FhjRnnaPy RD3OxVembtGN4uLqluqQSJLm+WC7Qv+pkfY7GSOTVv9XyaQ5+kxX1gxc7vKWGTLsA6jn IV8DmIEyEJ1Y9tLSbL4UoiojowMBMITbnj4iPH8I3FX4wSxR7xA8XY3KHut7f6nz10Vb /KuIiS8euIvxLNEUyq2u20gwrsMvoTaJ2nUXXQUFrsVbGccMRhZSjSzGBpxGpJqpUAg0 JYOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QM4Qg8bX; 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 f22-v6si2401987qkm.98.2018.05.16.09.04.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 16 May 2018 09:04:10 -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=QM4Qg8bX; 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]:53067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyuP-0003Ek-Fu for patch@linaro.org; Wed, 16 May 2018 12:04:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjZ-0004GY-Gf for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjY-00051x-Lt for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:57 -0400 Received: from mail-pl0-x22f.google.com ([2607:f8b0:400e:c01::22f]:46633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjY-00051g-GQ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:56 -0400 Received: by mail-pl0-x22f.google.com with SMTP id 30-v6so658864pld.13 for ; Wed, 16 May 2018 08:52:56 -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 :mime-version:content-transfer-encoding; bh=LQoF9e5L3ALMayOgvkerESyi2UVKdvRwamrm6aU1hPU=; b=QM4Qg8bXWNTgm4uQ5fsbDrbrATrAiqUVLWRxsAwQG+vHxB/ivBccUENHeg2NNrSH5r JNhcN7EXK0SmDLLpyCq8kgcfLi5ukH9vbVb2tosHO/A5GR5SfVhE78YO/S0DG3/KFvV2 ZbaJVrVbHiRBriWIe/QIc0mKIfz+oD8b4mMv4= 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:mime-version:content-transfer-encoding; bh=LQoF9e5L3ALMayOgvkerESyi2UVKdvRwamrm6aU1hPU=; b=EB50sOsXqCpHzfAlsGMv3sgoiO+SL6a3PDWpcIANblp63qWhTaqIJElqJHGMuQpugI +qGrvSr4tLrS+cjBSyV6j3ZBquv7BxZWUnDgu2HBoWXYRkt0qwLX6RBH/nw4H0hW5v8k vqzFqgpW4k5U/yy/Mx1FGGsiLtyzvGCZwb/un1F5ZVnVbG/d1UfsHK27rCpgjkv1eWJf X9aQUrO6EOZWVZFC0khywZa6FW1kJivIhLmo8rGz4MiYF9eeMNh4HdLOtAmcrHkpH5QF bAzopUd/puFYtVv+LCJvDjD1omCKBVOiFizwtWhc7oqKcX59Kk6ODN6yimtPM1kNEVMb 5m5A== X-Gm-Message-State: ALKqPwdY+cFrGmTse7FnLrV7ZNMPFVKJVrsnanMacVKEGyTPSRHrHjYL k3F4HxZzV2W1D2RAlRJZxMBLAQFsIh8= X-Received: by 2002:a17:902:aa94:: with SMTP id d20-v6mr1475103plr.323.1526485975043; Wed, 16 May 2018 08:52:55 -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 c3-v6sm4966632pfn.62.2018.05.16.08.52.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:21 -0700 Message-Id: <20180516155243.16937-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22f Subject: [Qemu-devel] [PULL 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Alex Bennée Reviewed-by: Alex Bennée 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 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)) {