From patchwork Mon May 14 22:11:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135760 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp187535lji; Mon, 14 May 2018 15:14:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrScIbHkA1N/ZJjzesc/pTx64WZ2KmAGgNFlCKlROqsauV23enghbjPQF3sGLCj/7enBnYT X-Received: by 2002:ae9:c10e:: with SMTP id z14-v6mr3562516qki.323.1526336079761; Mon, 14 May 2018 15:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336079; cv=none; d=google.com; s=arc-20160816; b=vYIEdyEVy3P4LWvBBzWok1QYKs+d7DWsWISm03M/KGSOTwlHdRT8rhqQR4zLIZFtyo v4v9jRe+jXR3VtThjNiH8c1MGQ4wzz0WnHpIyhLIiceJhXuk/0px8Fc2Jrrc8Ylmc2Rt Y7TOUCDy5fqZls9a26vVsl3zQrIqGhNfY0x4sUPjSh5DES3rCD/iSD2MgnM6xWhrdio8 rplUw12X5gZwfq6P+pQl6XgN4u2LX1k1MenuhfNqg2Z5EAUHnylcVqBDMMkktC7i7SPv Bqd4wJ+E9nP6ce1vp+MQHV6SJFNMzM7PUdjwX1xi6dPh+VFQDl+F1vsiwa2Basp30NoU 1TqQ== 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=VrjybWtyS9x1dk/X8ACHYXOClLJ40q5WBHgCIV0De2Q=; b=ZwRtHbsFcvEltHsaeqdF+bJM9+ecwmiQJhFLi7TW4VtDL0/m0eCoNVaKUrxEISUBqy n2vM5XloSC7HO2wntFK3EhnU/nd6dKRYIucbKeNjQkKOlYelI9lWC/9GgAU0jaENS/5/ ovZxt6iJe16C+EOoR0o6S0SGmnAxBWASv20gToX86XpXRP7Q5NqsTGElu0dGZGj2NP7y E3herPx4dF2kaf4EPO83BUV25sd5LiUzgoXve8zx7cJAy/ydqv55oqkoyFi3Ob9JgWn0 oZ1rGmqYAC2lYXnw0t90eh3tNWqEaMk6MMH2/UtAcWsZwV9omBl7030ucRvRcHH3IZ5U 7NVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WqRcg4+V; 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 r80-v6si2282053qka.279.2018.05.14.15.14.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:14:39 -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=WqRcg4+V; 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]:49881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILjr-0001GF-54 for patch@linaro.org; Mon, 14 May 2018 18:14:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhn-0007pw-3l for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhm-0007T6-3g for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:31 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:39313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhl-0007S0-Un for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:30 -0400 Received: by mail-pl0-x243.google.com with SMTP id c19-v6so8153090pls.6 for ; Mon, 14 May 2018 15:12:29 -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=VrjybWtyS9x1dk/X8ACHYXOClLJ40q5WBHgCIV0De2Q=; b=WqRcg4+Vqe4G0yuI0aKgKT2BmRX4A9RqASLhRtXu+IbKKTIKDTTfXh+DSG4cZI9cj+ iqxxspLnx9sqBRh5nUGffIQ1mhQRiBk6V5gZfyfiaaUw3Z8wrlA1uB8/2zsql+NyPhq1 jUe2PjaTiYRVOeWhsVUDHoiZgAPFbA1jhtKv0= 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=VrjybWtyS9x1dk/X8ACHYXOClLJ40q5WBHgCIV0De2Q=; b=H7V7FAceuMvTJftyRO52qIDV0lgyx0gl3ECkJFCuPANMnAYc0Ai2wHpBJL4RXEPOMY meealf2P8u3xz1qeaEGGTXKube+rVXrDUHWrJwCihD8VTmYdb05fQOisQt4glyG8hH5B k+ZzWBS1o3x/MhZZdGOStqQhTYaXOQ3+MTbT8N+nng9AotpeoAzXQbF7EZruaBjSdD6i F3c4I59zpLcZnMt40KFaBQhrWd1kpVY8zCCVRRUuYakSuI/nQGoCTU+IzsCC5bx3esxZ x/igb3Ev2L2bUZeI6fR0DT+OvRnDUJ9H6HB3WYNB41mwTIVnaWuCYEQRWsJ1moGjhu/1 4oKg== X-Gm-Message-State: ALKqPwf1gxqbHoDk3EBwGFkNSyZl43DyVdBSDybr0/hCocsz/Vg88Ygr qYX7FSYxQYMfsEPf6VTBXwJ4aKrTF88= X-Received: by 2002:a17:902:b68f:: with SMTP id c15-v6mr11566196pls.201.1526335948782; Mon, 14 May 2018 15:12:28 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:56 -0700 Message-Id: <20180514221219.7091-6-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::243 Subject: [Qemu-devel] [PATCH v5 05/28] fpu/softfloat: Canonicalize NaN fraction 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" Shift the NaN fraction to a canonical position, much like we do for the fraction of normal numbers. This will facilitate manipulation of NaNs within the shared code paths. Signed-off-by: Richard Henderson --- fpu/softfloat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.17.0 Reviewed-by: Peter Maydell Reviewed-by: Alex Bennée diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 0d17027379..607c4a78d5 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -330,10 +330,11 @@ static FloatParts canonicalize(FloatParts part, const FloatFmt *parm, if (part.frac == 0) { 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 << (parm->frac_shift + 2); + int64_t msb = part.frac << 2; if ((msb < 0) == status->snan_bit_is_one) { part.cls = float_class_snan; } else { @@ -480,6 +481,7 @@ static FloatParts round_canonical(FloatParts p, float_status *s, case float_class_qnan: case float_class_snan: exp = exp_max; + frac >>= parm->frac_shift; break; default: @@ -503,6 +505,7 @@ static float16 float16_round_pack_canonical(FloatParts p, float_status *s) case float_class_dnan: return float16_default_nan(s); case float_class_msnan: + p.frac >>= float16_params.frac_shift; return float16_maybe_silence_nan(float16_pack_raw(p), s); default: p = round_canonical(p, s, &float16_params); @@ -521,6 +524,7 @@ static float32 float32_round_pack_canonical(FloatParts p, float_status *s) case float_class_dnan: return float32_default_nan(s); case float_class_msnan: + p.frac >>= float32_params.frac_shift; return float32_maybe_silence_nan(float32_pack_raw(p), s); default: p = round_canonical(p, s, &float32_params); @@ -539,6 +543,7 @@ static float64 float64_round_pack_canonical(FloatParts p, float_status *s) case float_class_dnan: return float64_default_nan(s); case float_class_msnan: + p.frac >>= float64_params.frac_shift; return float64_maybe_silence_nan(float64_pack_raw(p), s); default: p = round_canonical(p, s, &float64_params);