From nobody Thu Oct 30 15:31:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525999580675537.8010903411612; Thu, 10 May 2018 17:46:20 -0700 (PDT) Received: from localhost ([::1]:36167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGwCN-0001vn-NQ for importer@patchew.org; Thu, 10 May 2018 20:46:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGwA8-00079c-7Q for qemu-devel@nongnu.org; Thu, 10 May 2018 20:43:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGwA7-0004pF-DI for qemu-devel@nongnu.org; Thu, 10 May 2018 20:43:56 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:38658) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGwA7-0004ot-8E for qemu-devel@nongnu.org; Thu, 10 May 2018 20:43:55 -0400 Received: by mail-pg0-x242.google.com with SMTP id n9-v6so1676603pgq.5 for ; Thu, 10 May 2018 17:43: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 y24-v6sm4216728pfn.23.2018.05.10.17.43.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 May 2018 17:43: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; bh=xs8P5M7KpsqqVNlyQrI1ugiUrrNAY5zDyuoghvVlkBg=; b=HhNlsV8ipXHYmwrqHYDIu7X1AGVgFdFBzHYH8LrsghYMPiqcbSreIUGTzP74V+fuzz dC92ti/8eJpzbWWpvyUZjnX3sAiIWmS/R9AaNuybniTi8wh1wVnnWmN0lHHeR3DJXSWp 8SGDc8K/wmuMVhGge2uAe1t2T6jAkTFeiW8Ho= 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=xs8P5M7KpsqqVNlyQrI1ugiUrrNAY5zDyuoghvVlkBg=; b=VNbDXbsEzPVDqUOPTV3U6FruHgBB0XgBC6vJhLJ6/h5oT/gyhBy+bxOep4bF/RRlM8 kzPs6PfHxrJQunufibr3trnJDq2GtuihCC6hIkpgqI918Db7jTQY8P3v2or0iX5jBLve rUXjVpWsi8QNxjDvgbyGhy3IJdf6vwnCtSGu8Mawhx27KysRwGTKmtm5AIpt8bu7QkXi nRlafUetJ73tPmO44fhqq3WEYBP5rTBqTchzCbJt9KUXt7LZS/m+QqfbzfM/gNTwx/ks rH16nLIahlCKN0VqLs1tNmfxG+B98xbH9zw/LHVr66NtiAXwB/7jvSuc5kQjCQMkEs49 wV4Q== X-Gm-Message-State: ALKqPwdYMgv9iCFlKg3bvoid3X6o3UvqyKgmPQg8uacpOSWIScrIKh+z /HHPSCpzerb5QVYPYJ2E0TGIEr97EQo= X-Google-Smtp-Source: AB8JxZotueHTjij7rm6kDoi8s0pF3OhDsE9e2zBQCxoADzY1NvYb32MxwM11RVEGN/jx9KuZxVOwTg== X-Received: by 2002:a63:ae49:: with SMTP id e9-v6mr2670256pgp.38.1525999433935; Thu, 10 May 2018 17:43:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 10 May 2018 17:43:30 -0700 Message-Id: <20180511004345.26708-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511004345.26708-1-richard.henderson@linaro.org> References: <20180511004345.26708-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:c05::242 Subject: [Qemu-devel] [PATCH 04/19] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Shift the NaN fraction to a canonical position, much like we do for the fraction of normal numbers. Immediately, this simplifies the float-to-float conversion. Later, this will facilitate manipulation of NaNs within the shared code paths. Signed-off-by: Richard Henderson --- fpu/softfloat.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 5e4982b035..df377b6314 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -329,10 +329,11 @@ static FloatParts canonicalize(FloatParts part, const= FloatFmt *parm, if (part.frac =3D=3D 0) { part.cls =3D float_class_inf; } else { + part.frac <<=3D parm->frac_shift; #ifdef NO_SIGNALING_NANS part.cls =3D float_class_qnan; #else - int64_t msb =3D part.frac << (parm->frac_shift + 2); + int64_t msb =3D part.frac << 2; if ((msb < 0) =3D=3D status->snan_bit_is_one) { part.cls =3D float_class_snan; } else { @@ -498,6 +499,7 @@ static FloatParts round_canonical(FloatParts p, float_s= tatus *s, case float_class_qnan: case float_class_snan: exp =3D exp_max; + frac >>=3D parm->frac_shift; break; =20 default: @@ -1264,13 +1266,10 @@ static FloatParts float_to_float(FloatParts a, } =20 /* - * Our only option now is to "re-pack" the NaN. As the - * canonilization process doesn't mess with fraction bits for - * NaNs we do it all here. We also reset a.exp to the - * destination format exp_max as the maybe_silence_nan code - * assumes it is correct (which is would be for non-conversions). + * Reset a.exp to the destination format exp_max as + * the maybe_silence_nan code assumes it is correct + * (which it would be for non-conversions). */ - a.frac =3D a.frac << (64 - srcf->frac_size) >> (64 - dstf->frac_si= ze); a.exp =3D dstf->exp_max; a.cls =3D float_class_msnan; } --=20 2.17.0