From patchwork Tue May 15 22:25:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135935 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp73570lji; Tue, 15 May 2018 15:26:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrLZbzZpUS2mwerFeRdSrdzGdjc2ozc4gDsLayrNy9tdFsSR43GGzjtrLO8z7bH9LZBsfR6 X-Received: by 2002:aed:2b03:: with SMTP id p3-v6mr15426534qtd.44.1526423192895; Tue, 15 May 2018 15:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526423192; cv=none; d=google.com; s=arc-20160816; b=PnYj5RE+sbTLqi0cmY36TaxRSpq1WTyiDDJTxP6pronBoufgMTKA7V9DcbVB9ratQp vkRIesjTH+RVD+W1sLZ4AXYE18knHjh/MPTHUlDQ68I5kAut6xVo1bY6vhhmMBIHjdg4 Z8lK5sxqTZ6EMPmyyKDMdj8LxQVSxJMpDhc3KVaDuEbKJgRAV5MAXKIWgx5iz29SSnms ZXqk/S9/2HPcWXGv060OX0mA2GmPksY6k2WL9NGC4ZFi0vUqZMqe41tCpkta4oYYR5Io dG3JQZ9cOxVyliOLQ2qkhR94/2qksC6MDiOI6gO2fq7GeEd21qeA8ikPBeBLdnBuLXQg RqLw== 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=HxQqECksCkJpdGoEfFndaESXVHpm3z8jUy+h96CxH/UUVBfhimerXY7DO3jGcCD/RB eRUv3MUMd9tSjwD5DH0TEBx9cIyvKoo+BEIjmx7gUSanAvI9r9AFlMsadX/awI3PyoA9 S1iF6Fs/ofaKgz0JdT3KaLglRAzpGmxeYfwdSsKBmYU96Xo7ZpngrJoC53rF8CPmc0uU bPIsvBqkrI76X7d+2lsFftMpwt5vbD8LckHUjJm2gWJPxRRPxXJqwab5dBVnKZ4cJ8Tn P7X61sHmzFDWYK53Cm9YRMkLzhe6KdtUg4bo1RB2xYnOG90wpdy10mNi0kb7mTC4azKL jyUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NDocmVZU; 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 e43-v6si1159845qte.257.2018.05.15.15.26.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 15 May 2018 15:26:32 -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=NDocmVZU; 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]:36305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIiOu-0003Qe-76 for patch@linaro.org; Tue, 15 May 2018 18:26:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIiOK-0003KU-1E for qemu-devel@nongnu.org; Tue, 15 May 2018 18:26:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIiOH-0004Cv-Qk for qemu-devel@nongnu.org; Tue, 15 May 2018 18:25:55 -0400 Received: from mail-pl0-x22d.google.com ([2607:f8b0:400e:c01::22d]:32834) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIiOH-00048Z-Jl for qemu-devel@nongnu.org; Tue, 15 May 2018 18:25:53 -0400 Received: by mail-pl0-x22d.google.com with SMTP id n10-v6so872861plp.0 for ; Tue, 15 May 2018 15:25:53 -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=NDocmVZUOONUOfeN6IKcLHJXGoyvNK2Y5NvMxwiShq7jEiJctX51M35yf55RsnP4br 9kRYsEIbh9uLQ7B2YpNRrSkfs0De6/5kxaviSgvHyD7W3uuZe/IZ8sS49w2UIKQAtxkV q+nwOnpOZJQ2BYWWarLMsmDQn8YGaHbjHycTc= 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=fn3CEraXWK9uElJMzq4YTPl+g78jR8nlJ1oKHb/c1vRN//bIIQj8q/PhHq/CgvTIH+ yq4dulea4Dpcg0s+2KgBUmhf42y9bn/O46H0u0gGU5RWK35HayP1s1RUlC/BY2pVEHkh ft+ub2/n0VG4PkyU48PxIxcePlLAxvweRST8LmPsfvJs1JBw93fw0wIKerN57uMLzkYQ 9AI8QwSu3xIfMVRXABZhDXQEsZUsoG/ADAg0P+1wQ0bRyzXPHfkN2JdXovalReNjfk+o cX3BJKVGly/sPmGPrglzEY0QtZGPaMJ0R/abAP+VqgkkJbwTlbRwJel2gsrNZIT09EJ0 Dnjg== X-Gm-Message-State: ALKqPwceYDXI4CEAZKa+bvjtQLAg8TDJ9kY81lmjKpCkivRLfuHPqnug V52ET9EoETqTDXBn1JLOzyKxUG1WLaQ= X-Received: by 2002:a17:902:8f97:: with SMTP id z23-v6mr16542537plo.329.1526423152336; Tue, 15 May 2018 15:25:52 -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 g11-v6sm941419pgq.62.2018.05.15.15.25.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 15:25:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 15:25:18 -0700 Message-Id: <20180515222540.9988-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180515222540.9988-1-richard.henderson@linaro.org> References: <20180515222540.9988-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::22d Subject: [Qemu-devel] [PATCH v6 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" 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)) {