From patchwork Tue May 15 22:25:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135946 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp82710lji; Tue, 15 May 2018 15:36:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpm38ycUnOyRtswyfOc7lPaPrywchE74bDPO2hX5shQdlOq1qYA7vfv6TXiNym3EWT02E34 X-Received: by 2002:a37:6e05:: with SMTP id j5-v6mr14193324qkc.51.1526423786952; Tue, 15 May 2018 15:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526423786; cv=none; d=google.com; s=arc-20160816; b=nH1yO0kAdAmCsGtL4wDzSDZFiexNvl2951D13WcZnVSVTrA6lrqd+lwlRQiyvlLWFv PtLawRnaWDtuiZIUd2D9Qp5lP4ZoD8jvzIBDqzAqGmUz7ECA6JLKr1IYudWBobtMxLKE cLSj7KbQprffXcBjx2jbGxY9QwseBKnrS9DnEagxnO6tqv87y/n6dpVrnj1txJb4S+P+ EJzzX+B6wFFDFT+nwKEJ8H3LrOVU4kdnlo5Tmd9n4HWRwHXVnoAuV+ABnv5aDrd9zFjH W9byEh2sHinEBCatysRu1TaeQ0GqGDjlqlT+1yTfif7J+VOAXMmk00qmHAhQKZiKsOci Zo3w== 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=/xl8f2zQlEINP9lneuf7ucQwkBVVFUmq+tNHsXqCle4=; b=j+rfVKtzEUtlBFistxfHC5JKituPUkfcYTZsy4aoNc/34eH36An716v+G3sjbJezf6 ovZRW39dbGNcjM2qrxRpci1DKzFDAamURGmC1aoiWL2Ch3B4RXUOM3PT3SH1Ze5SMvPk ORn2knYRBGhnP9BuZgmuJnZn9EtOKnCeAiLcZLraBtgmTwtY9dEYmrFgV8zawZcGiJG3 o0tNal3FkAnVdtLu67V1xf1CczQsHU4Z4/RDzPV0W3GZ+Wgv/j72QQZOllyvSzw22nHs NzlQOVzyzJiXLWa2zv8R8HA13X7ibGhnn6DCsPS35R6uHolucdCmKzx1PmjUHm3kwvf2 ouzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KAks+qfN; 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 y7-v6si1060714qvl.90.2018.05.15.15.36.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 15 May 2018 15:36:26 -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=KAks+qfN; 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]:36362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIiYU-0002LZ-Cv for patch@linaro.org; Tue, 15 May 2018 18:36:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIiOI-0003JZ-Sw for qemu-devel@nongnu.org; Tue, 15 May 2018 18:25:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIiOG-00044g-Jt for qemu-devel@nongnu.org; Tue, 15 May 2018 18:25:54 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:40241) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIiOG-0003yh-Ck for qemu-devel@nongnu.org; Tue, 15 May 2018 18:25:52 -0400 Received: by mail-pf0-x241.google.com with SMTP id f189-v6so736075pfa.7 for ; Tue, 15 May 2018 15:25:52 -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=/xl8f2zQlEINP9lneuf7ucQwkBVVFUmq+tNHsXqCle4=; b=KAks+qfNdDptnN3Gu5xQRRh+cEDmQWZ3Tf7fObac4IOVwGW4WgIG35YwO2ao5yXWPm rdOrtu+OrKiinPfCU/zp48QLUUA7wEFG82bZg+fLQRKh7IhdGuuarR49jrfQ5dsu34wP DRuT10BaRIzFSXIkUp5GByi67VI/x/esQGI5I= 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=/xl8f2zQlEINP9lneuf7ucQwkBVVFUmq+tNHsXqCle4=; b=KqgDRmGZZokACbu2p8ZUe0KZam4W+mlpVxY+odOcY9D7CMnlbl2h8kWIY2WMPtPrbx XYM7U2I5M++QA2j1thB/htgWyRK6czV70Ry0U+tHVLHrOCXDH/DrIBJ0rTW5nw6MjLag dCGEiR4+Uq6iGJn4vCyDfIBRNcEDlQMdet7mjDfxShF8ELM/c898XNIFwqsNIHHPDp9P /KWZqzDej5ntOYP1NwDvrPTlJbATHWeRoLE4/pScuqk9twz2gr9csP9SlLgq3Bf5cXBL KePlMSTQGEJeMyOoKrmVGsmMiDYoGhNoEeroemuJqNwnii5edrsbjbDDeY/1mCO7uUgm 1yew== X-Gm-Message-State: ALKqPwfeRqrmI+G1epo6LWsYd2S18NK48y4AxKqLqoInSv4u5rKesX9Z vGrw/H9YSZ/rl4wLHbMywqQkE1er79A= X-Received: by 2002:a63:bd49:: with SMTP id d9-v6mr13963324pgp.14.1526423151110; Tue, 15 May 2018 15:25:51 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 15:25:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 15:25:17 -0700 Message-Id: <20180515222540.9988-6-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:c00::241 Subject: [Qemu-devel] [PATCH v6 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. Tested-by: Alex Bennée Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.17.0 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);