From patchwork Fri May 11 00:43:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135445 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp245876lji; Thu, 10 May 2018 17:47:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZonmHfq6+qYes7xMoNBqOXgs9HGSiT1+zXPpesqHWURMlEYYVSKrg2vFOAIdVXVHrDcT5iK X-Received: by 2002:aed:2984:: with SMTP id o4-v6mr3560441qtd.124.1525999632916; Thu, 10 May 2018 17:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525999632; cv=none; d=google.com; s=arc-20160816; b=XhpM2XEz4kqO6W+t68aIJdXP8Nz+ZMWgiKHquLxExn/YVFJ7nBE6i9Q9gjfzAhXQOi DZLdKSg1FHP0MHkH+a8U95f7yJIQqTW+zwpMaB37LjW+QUDmUdrGwaFJO6mD2RBUk57W WmRoKqUxFNiTazjWKLCTyDrRarUOVf3bQ2KZPnHoxUKOSza6jKIQfiNnDmbYvMByG0Ng /HrBaNXsYHzrTtyBae5PNzwY03Mt/rDTLzR+2rE+HCaDyOCNZ6taa+Dwv1dO24h22TEy T3/l+lz9/8xzc+cbo18lq0JZoaLHdl+IrEo1WQGqPDSBIbnj46F7baRHandlcT+k0zWM vjCQ== 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=xs8P5M7KpsqqVNlyQrI1ugiUrrNAY5zDyuoghvVlkBg=; b=aGaNzQ3az1u9zWKJ/hzqQBAMJNAVLIMNdx6xvLfTmSImsMpsIHsrAEkP0KQ3u0nFWa fPnS6hRoNY//zV0KSYOHHdCUzwOYWX6KzU/4LOH2p5Aef8XPGJFf8vv1xjQoUdG2VjQ/ L8lrsXWRl7mePNyCFRMcLmh7mZzbCQzgFEoAAEawQGE4Tv254EjGCCIOEN3sQSFGiEh6 bHaBQooJel5jeKfeixjLZZkIFU1rVL02vxUEZiJEsX6w7yC+FAb7YHd1QeGaVEeE5nUC hLTAQYHhmhpntA4TuaUPEoRJ0t2naQdD29gWRTwEuETs3p8ctGkYoeZC7gMf1oY+QZuc fxQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HhNlsV8i; 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 p19-v6si1960717qvm.42.2018.05.10.17.47.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 10 May 2018 17:47:12 -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=HhNlsV8i; 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]:36171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGwDI-00031s-8P for patch@linaro.org; Thu, 10 May 2018 20:47:12 -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) 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-Received: by 2002:a63:ae49:: with SMTP id e9-v6mr2670256pgp.38.1525999433935; Thu, 10 May 2018 17:43:53 -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) 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+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. 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(-) -- 2.17.0 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 == 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 { @@ -498,6 +499,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: @@ -1264,13 +1266,10 @@ static FloatParts float_to_float(FloatParts a, } /* - * 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 = a.frac << (64 - srcf->frac_size) >> (64 - dstf->frac_size); a.exp = dstf->exp_max; a.cls = float_class_msnan; }