From patchwork Fri Jun 5 19:00:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 11590397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E7E4618 for ; Fri, 5 Jun 2020 19:01:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F24A32077D for ; Fri, 5 Jun 2020 19:01:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F24A32077D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:45408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhHab-0000TF-Tu for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 Jun 2020 15:01:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhHZj-0007ng-Oj for qemu-devel@nongnu.org; Fri, 05 Jun 2020 15:00:19 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:33964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhHZi-0006kF-Sc for qemu-devel@nongnu.org; Fri, 05 Jun 2020 15:00:19 -0400 IronPort-SDR: 9GYcwDgzUE23Zz9Jpn/vvQdCGmbQtwS2G28xA4vme/GAffyb8iKOBIY/oCDOnlOYw54MOqueKd sX9+zpWbvN/tjd4ouhXrnOcXF2gKjiZAaXfRrNI2MwSt+fuct1e6TEsPvgVFl0Wcje7b8gJxe1 co7Ck+V4F9dpryuI8TdKrSVyJKKwKKX6JkctrXEbn/yiq6mPe5Ig/SQylF9l/X7SxfNyVFYdjg OSFskJxj8uYEfQf6mKjPJktXTc5EMAubSlU/+Db5kUDwaGbvHnRb4GFe8zYnLfhbRXHiIeVfWg ceg= X-IronPort-AV: E=Sophos;i="5.73,477,1583222400"; d="scan'208";a="49633038" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 05 Jun 2020 11:00:17 -0800 IronPort-SDR: F/1FruGMO9R7ujubsMTUScSsM8Mx4W2Fh5rWxXLYYxsGY9wrtJq5kU0mA1aJ2JrIGkbkAFNdis sOixld8CnN58F1VpLQSeM9EipzExRbuwSgoaoy7IaMOVqyAtZekhdwyQtNi+Nxwk6XfbmT1qDy qZ0qx/q6L0cH8RYLyGtd4Eeyx/nBq/XEgl5QshxttGwCsuQ87mf7Y3+iTybqIduvkJ2xYb8GC7 gZuZ3J0vxk0ZCc04k4jy0V2/36aN6F2iQ/fetXsaVmd5/PP01Gt7xcjYh4UrRKWTNmdbdNjqc7 bOk= Date: Fri, 5 Jun 2020 19:00:11 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: , , , , , , , Subject: [PATCH 2/7] softfloat: fix floatx80 remainder pseudo-denormal check for zero 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-02.mgc.mentorg.com (139.181.222.2) To svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) Received-SPF: pass client-ip=68.232.137.252; envelope-from=joseph_myers@mentor.com; helo=esa4.mentor.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/05 14:59:46 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The floatx80 remainder implementation ignores the high bit of the significand when checking whether an operand (numerator) with zero exponent is zero. This means it mishandles a pseudo-denormal representation of 0x1p-16382L by treating it as zero. Fix this by checking the whole significand instead. Signed-off-by: Joseph Myers Reviewed-by: Richard Henderson --- fpu/softfloat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 7b1ce7664f..091847beb9 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -5726,7 +5726,7 @@ floatx80 floatx80_modrem(floatx80 a, floatx80 b, bool mod, normalizeFloatx80Subnormal( bSig, &bExp, &bSig ); } if ( aExp == 0 ) { - if ( (uint64_t) ( aSig0<<1 ) == 0 ) return a; + if ( aSig0 == 0 ) return a; normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 ); } bSig |= UINT64_C(0x8000000000000000);