From patchwork Sat May 12 00:42:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135591 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1566438lji; Fri, 11 May 2018 17:47:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrHdSfrvPg+hLeop/gfavmWrtbC9SEZnGUCR48p1CiEWFC0iRcW3eCawYatVbzFaC8EHJvi X-Received: by 2002:a37:7f46:: with SMTP id a67-v6mr250047qkd.328.1526086036739; Fri, 11 May 2018 17:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526086036; cv=none; d=google.com; s=arc-20160816; b=hFqZAFQyu1BBzGTkx1GqCB/73TlmAJjG/ZEs4UkBeaP05Oz5ePMiJWuHTi8DprQLmz IHjn0DHFZPtqAD/wdwAI22vrAk2YesyrA14j3eGZnkr5pnr0gnXGzKG+0OyRidiHIgYG 4VWVTwTHewB5bvmWkDficZR9B3QuxAQi92ceG9/452esOrdK9B5gnzhoGuQKGZJSIx8u W6v80W8l2Niyk5Wa4az35FxO8hUEiGepSS+ycEDrIYruGtOZqBU4GRKvmkXBXztZvOQY CYWQQhNQ6SfPrqiu+iEtN58LQGyuJy3lhnmtGBa2smBkFeAj/Y/lF775iR+9R3u/rtu8 6guQ== 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=YDzpf8JdwZ0xAB5562vl+r2U0ux0aekXDL/EfP74jnQ=; b=KqRf1rINJrNoeF6fle+o4jfesJlHWHtVaP/Y97ZfYQmdMLuYa8ndmPy3fN8FrZqnbd dfeNzf58Mx3pe0fKd5U3yxbNlaA45dlzhaJLiV4qSUfQ3OeIIFNlH/dDRH9E01uPShbB AfM67L2/liG9rFSi00F3b0I1VqXMNFJU8saqD25DIgKF3uW2WalQq7Q7y3qlL4S/XHdc O0ao27hNz/kcD3UDMsqAe321+LFCLGNiQY6Bzy7hJFLK2SbNyumG2j3p5ijFgprC34H8 jlbluqIIP98DJix1D50TB4dciaKpfsHm+npTKvWDO2+Ko8x0958mAzJw734PeQOdwvlq dsNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BN4wHySX; 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 h58-v6si4298572qvi.184.2018.05.11.17.47.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 11 May 2018 17:47:16 -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=BN4wHySX; 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]:59125 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHIgu-0008JW-8g for patch@linaro.org; Fri, 11 May 2018 20:47:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHIdB-0004Ef-4v for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHIdA-0002qY-Fe for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:25 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:42718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fHIdA-0002q6-BD for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:24 -0400 Received: by mail-pg0-x242.google.com with SMTP id p9-v6so3076393pgc.9 for ; Fri, 11 May 2018 17:43:24 -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=YDzpf8JdwZ0xAB5562vl+r2U0ux0aekXDL/EfP74jnQ=; b=BN4wHySXTZ+qrAn0DbrTepDN/cZ/khcLvbSS3wvoPCgl9jTg/2DtTqBBKidJkFSUzR XCJi9Ipk+9PgZBtAZegvPhvB1H9aSUPxsjOTGpN8h9KsA7S7XrUYINz4tvc0u+fZiOqI p+H440Gvl3qdXA3pIxQQx8UWCSgHuS+RCkQIc= 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=YDzpf8JdwZ0xAB5562vl+r2U0ux0aekXDL/EfP74jnQ=; b=T9yWsfjfr+KE1LC+1aeWtvfwzBcYFOiOu1ZiH7KcAsuTrPS2WXnRKdgzBswOehhME5 SztvIrGn2+KikyxMexGjvtwIr2hzCXCXIciYF69oDow6hmJRfCiTNaRg8oTcP697/SSE IMsQRA/n7PhIJL643cX0FJ38VA+MRVQ+wu1GE0pX7cX0NmcCJKjjoja6PE0IfOrMx9rv JBihyN0Q7mwd9kik69g1Rx3kE9kF1s/k4eiiTAH04y+PH7txIxSkSKeXy3EET1Gj1S3f bQlzEyumQgdNV6sj9/dYVfDzv95KW+zIxre/FEV+hNgF8QSz9b20GcVNr/FhTBHIzImZ mjgg== X-Gm-Message-State: ALKqPwcix43ykfv0x/V48Rw3TUzyf2ljpDgXrS/2DaLdrIXtfJzuJFB/ rCoahLExAgnOyEWNWQJIF42UTl3jEsI= X-Received: by 2002:a62:db05:: with SMTP id f5-v6mr972693pfg.137.1526085802747; Fri, 11 May 2018 17:43:22 -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 k84-v6sm10756406pfh.93.2018.05.11.17.43.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 17:43:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 11 May 2018 17:42:50 -0700 Message-Id: <20180512004311.9299-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180512004311.9299-1-richard.henderson@linaro.org> References: <20180512004311.9299-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 v2 06/27] 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.17.0 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 353893aaea..a56d3d975b 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);