From patchwork Wed May 16 15:52:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 136016 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1101618lji; Wed, 16 May 2018 08:56:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq1d+KW2LVA7fX6TVs1m8x7L5HsRfhiy8VRP5691VvBMsXigMmUo3JEJvRPtNg0og6rTWS7 X-Received: by 2002:a37:80c7:: with SMTP id b190-v6mr1464061qkd.212.1526486194641; Wed, 16 May 2018 08:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526486194; cv=none; d=google.com; s=arc-20160816; b=o3almKBtn6hCY00CknOMY7H3D66udAIEc7EV6a3HWhgRpuA5JgJmYyw59YVWDxw3XE oPQIczziKIu0+CDrL/VWiLyJsnBlmySO9CADczJRlm6PysQrOhfruyC0fZPuox7wYKGj yqbpmRUl/I72l4kJcn07xEvOKdzwHtn2SeGkKn0RSWSOwxG4RKS1K77X1zmLTRsIWF8J cYH0SMPBDutAluiOd9Vq4ft8fc+RxQ6uFJLo+kFuF/vPrYR3bZnxx6e5muKLJ9tpZqpA hjPc//VwvJYRwjLU5xrD0dZ2Rc30DMbaMNC+nY6J0pSY3kVFaSyy+y0tf7xHAISQ36mv 3iYw== 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=Jo+yVKI4BsE71pX4FeSeyyWr+lQECT/WpdGEl44R0pU3qmnqE+ugvt6lx4jJ8JKact CD2qmBFEonfhioCTeFyUnRd0drGJBg/kmpTxXmiGivzjp3QCFtI1ajKOn8ckcgJeHbcM NzttXP+SE/DMVg1X1HIvFaNBq7MuF+0ULHV/9DBIi4LPc0Wu4BOdomDJLUqS6iCRNOkS ZPyeXCDg4LYaGli7pPftJIystOOFIN2FbIv16QzcbWRO7kG93mN2Ow73Ok0IYUiXcu2y +r1KNlzFduTGkn/kfyYuJMILk2OnHkGpeuPE5flcfgJl69sU5A3cQX8NBjuWYlTY7BLU 372A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X5MWqfYR; 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 r11-v6si3010960qta.137.2018.05.16.08.56.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 16 May 2018 08:56:34 -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=X5MWqfYR; 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]:53008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyn4-0006qO-3f for patch@linaro.org; Wed, 16 May 2018 11:56:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjX-0004EQ-IS for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjW-00051K-MZ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:55 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:40989) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjW-00050u-Hu for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:54 -0400 Received: by mail-pf0-x241.google.com with SMTP id v63-v6so563115pfk.8 for ; Wed, 16 May 2018 08:52:54 -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=X5MWqfYRq3lyYNEvIkPJQyygoChOnQSLzWXGX5Cqyiyl65HpkbWBti7D8CopmhgtLR sZPsVsYOHM43jpRVWk0PaFkA+MOYEHv0Gt5UJBvXb6Pt3CIifzBoxWvLzBzcY2qDg/2S FOq2hkcgzP+XYCiJdNnOKdfthjkUsaEViGr/4= 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=k7eFINcU4/zM4WLO/SxcfktXXLAQQYIkUwmwsX9Hl50vt2nLI+BpeCxObE+rUC/QiH +dtEn7uAfEHstBERSQH9v/Fgve/5g7+f4TST6FxZh+rC41NyymevQNCtbX3f07ZWq9nE kD1ZP5OFJ8cO8PC7rkjJ80O9st3Ps1B59wI2ZkX1yDV9jt5+aDPBRnsoPyG2hwZER3RU KS2eUM4LID8cBHAD7La6GKUlauoIZjOk7W4kgQRW2Ik9R88lVLKKtQZPgeu4Bw0/WV7H odjnLFlm1j+S6A3d5aczPZwu2o+GNZrKs3MLv++e+h9hJTjAqAM/wF3oOfq7J5W1zrxC Q6Rw== X-Gm-Message-State: ALKqPwdehvOEnTwoR2KuzNBm6Se5YJh3jINhMrwMdrlTfURV1BqrY2VQ aNDgKuiImEQKXsj5VrF+JzKDU0/eN4M= X-Received: by 2002:a62:4c53:: with SMTP id z80-v6mr1484056pfa.181.1526485973237; Wed, 16 May 2018 08:52: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 c3-v6sm4966632pfn.62.2018.05.16.08.52.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:20 -0700 Message-Id: <20180516155243.16937-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-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] [PULL 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 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);