From nobody Tue Feb 10 07:40:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1591635698; cv=none; d=zohomail.com; s=zohoarc; b=X8ja9HU7DOoo8nyen2W/lvshds4JzX0nAzr9PJzmN54tySikMLesb0UjrBpdkoaLNGXzon8UwYCW8D+h3YhyZQ/8GC1pTefSSRP5z8Q827PWiUKbS54GnCRntTOHUP73ZNAmd/uXGRClIvtrCbYukwG3JgBXR4IuK4HQzZRNXoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591635698; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ai5kGEZXPslFDlk7OhlxqULt+o2RFGEpWWzu2/1Xoyc=; b=iW7H5jerOTiBfmhHuqZhOisWfKEq0qSTS0uWBRkAWu2kyjpskb4a/nJZ2YkJnvt9vaOT9eQEVsrxE8kpc80ZY57QfpHi69FnOO1yvh0tq+46tH8blUkQX8wvjr+nr1hqt4ZN8+kNA1jsbeqCEPK7IN0oz9/IGtLkgcbmBRDzxBM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1591635698989678.1716454750888; Mon, 8 Jun 2020 10:01:38 -0700 (PDT) Received: from localhost ([::1]:52734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jiL9V-0001fq-EL for importer@patchew.org; Mon, 08 Jun 2020 13:01:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiL4X-0003Kd-UB for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:56:30 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:48649) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiL4X-0001LY-00 for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:56:29 -0400 Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 08 Jun 2020 08:56:26 -0800 IronPort-SDR: kl0vj6Mr8xlsqc0ZPewTID8PjHyUVN5Bm0VuSHKD9aTHIFDsUxxwumKi1+j741QL8Z6GujWbI3 Q9e8ABmBkVexa79LKrXOyk3bFyRY+Iz7ILFNcqUFTuLsPSeEkodOstO5RB+e8vddT8AK6iSgal VCMxO6EJxtE/ou5SSedK3U35fuP0bbgw+ipOwSsY2OvZBPgKENOH2g4PBZQ7fZpIbMS8JXxje6 GQwtqdQMNJQOKomTqWf9bCwTwFt57B1vhlF7neMiRocUJjMSP840oKuX2xl9Tuhg2cXTDqsxeG OZw= X-IronPort-AV: E=Sophos;i="5.73,487,1583222400"; d="scan'208";a="51690305" IronPort-SDR: +JtsbNUMQ1IT1m9Bp/ebcLXS3sI9oApZzrdNE5NNsOeKnbs1RVjviWzI7Xw6hXMgsrMA4/u1cw L4gToIW2LUVJEi2jm2LSyeVJbAvX2EL6h75NDZziarCbqf7vtLm8ZgFuXCJpMrorStt/+YBJmL NkOvv9k3Q0yx2G5ILwU40ePW3YaNplSWTdLPkPKFzwQL8XejcYqkXzw3Sf5P9hqgZF2e58bT5L 55LH+rxTlKp+5EbzCSDUXLThKcfdxPyF4xGU/xLyfaDpwDEf4bNgEoLRkktTpP0iObFoeQPcY4 ve0= Date: Mon, 8 Jun 2020 16:56:20 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: , , , , , , , Subject: [PATCH v2 3/6] softfloat: do not return pseudo-denormal from floatx80 remainder In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) To svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.129.153; envelope-from=joseph_myers@mentor.com; helo=esa1.mentor.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/08 12:51:54 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The floatx80 remainder implementation sometimes returns the numerator unchanged when the denominator is sufficiently larger than the numerator. But if the value to be returned unchanged is a pseudo-denormal, that is incorrect. Fix it to normalize the numerator in that case. Signed-off-by: Joseph Myers Reviewed-by: Richard Henderson --- fpu/softfloat.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 091847beb9..9d43868e4c 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -5691,7 +5691,7 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, bool= mod, float_status *status) { bool aSign, zSign; - int32_t aExp, bExp, expDiff; + int32_t aExp, bExp, expDiff, aExpOrig; uint64_t aSig0, aSig1, bSig; uint64_t q, term0, term1, alternateASig0, alternateASig1; =20 @@ -5700,7 +5700,7 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, bool= mod, return floatx80_default_nan(status); } aSig0 =3D extractFloatx80Frac( a ); - aExp =3D extractFloatx80Exp( a ); + aExpOrig =3D aExp =3D extractFloatx80Exp( a ); aSign =3D extractFloatx80Sign( a ); bSig =3D extractFloatx80Frac( b ); bExp =3D extractFloatx80Exp( b ); @@ -5715,6 +5715,13 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, boo= l mod, if ((uint64_t)(bSig << 1)) { return propagateFloatx80NaN(a, b, status); } + if (aExp =3D=3D 0 && aSig0 >> 63) { + /* + * Pseudo-denormal argument must be returned in normalized + * form. + */ + return packFloatx80(aSign, 1, aSig0); + } return a; } if ( bExp =3D=3D 0 ) { @@ -5734,7 +5741,16 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, boo= l mod, expDiff =3D aExp - bExp; aSig1 =3D 0; if ( expDiff < 0 ) { - if ( mod || expDiff < -1 ) return a; + if ( mod || expDiff < -1 ) { + if (aExp =3D=3D 1 && aExpOrig =3D=3D 0) { + /* + * Pseudo-denormal argument must be returned in + * normalized form. + */ + return packFloatx80(aSign, aExp, aSig0); + } + return a; + } shift128Right( aSig0, 0, 1, &aSig0, &aSig1 ); expDiff =3D 0; } --=20 2.17.1 --=20 Joseph S. Myers joseph@codesourcery.com