From patchwork Thu Jan 13 19:55:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 78807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 13A31B6EEB for ; Fri, 14 Jan 2011 06:59:32 +1100 (EST) Received: from localhost ([127.0.0.1]:54733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdTKT-0004Jf-E6 for incoming@patchwork.ozlabs.org; Thu, 13 Jan 2011 14:59:29 -0500 Received: from [140.186.70.92] (port=45363 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdTHG-00020M-10 for qemu-devel@nongnu.org; Thu, 13 Jan 2011 14:56:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PdTHE-0003Ac-9n for qemu-devel@nongnu.org; Thu, 13 Jan 2011 14:56:09 -0500 Received: from hall.aurel32.net ([88.191.126.93]:36473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PdTHE-00038y-5A for qemu-devel@nongnu.org; Thu, 13 Jan 2011 14:56:08 -0500 Received: from [2001:470:d4ed:0:5e26:aff:fe2b:6f5b] (helo=volta.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PdTH4-0006Rc-Bp; Thu, 13 Jan 2011 20:55:58 +0100 Received: from aurel32 by volta.aurel32.net with local (Exim 4.72) (envelope-from ) id 1PdTH5-0002KM-Sb; Thu, 13 Jan 2011 20:55:59 +0100 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Thu, 13 Jan 2011 20:55:59 +0100 Message-Id: <1294948559-8913-1-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 1.7.2.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Peter Maydell , Aurelien Jarno Subject: [Qemu-devel] [PATCH v2] softfloat: fix floatx80_is_{quiet, signaling}_nan() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org floatx80_is_{quiet,signaling}_nan() functions are incorrectly detecting the type of NaN, depending on SNAN_BIT_IS_ONE, one of the two is returning the correct value, and the other true for any kind of NaN. This patch fixes that by applying the same kind of comparison as for other float formats, but taking into account the explicit bit. * v1 -> v2 - fix sign of comparison - add a comment about explicit bit Cc: Peter Maydell Signed-off-by: Aurelien Jarno --- fpu/softfloat-specialize.h | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index f293f24..62a980d 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -468,7 +468,8 @@ static float64 propagateFloat64NaN( float64 a, float64 b STATUS_PARAM) /*---------------------------------------------------------------------------- | Returns 1 if the extended double-precision floating-point value `a' is a -| quiet NaN; otherwise returns 0. +| quiet NaN; otherwise returns 0. This slightly differs from the same +| function for other types as floatx80 has an explicit bit. *----------------------------------------------------------------------------*/ int floatx80_is_quiet_nan( floatx80 a ) @@ -482,19 +483,22 @@ int floatx80_is_quiet_nan( floatx80 a ) && (bits64) ( aLow<<1 ) && ( a.low == aLow ); #else - return ( ( a.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( a.low<<1 ); + return ( ( a.high & 0x7FFF ) == 0x7FFF ) + && (LIT64( 0x8000000000000000 ) <= ((bits64) ( a.low<<1 ))); #endif } /*---------------------------------------------------------------------------- | Returns 1 if the extended double-precision floating-point value `a' is a -| signaling NaN; otherwise returns 0. +| signaling NaN; otherwise returns 0. This slightly differs from the same +| function for other types as floatx80 has an explicit bit. *----------------------------------------------------------------------------*/ int floatx80_is_signaling_nan( floatx80 a ) { #if SNAN_BIT_IS_ONE - return ( ( a.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( a.low<<1 ); + return ( ( a.high & 0x7FFF ) == 0x7FFF ) + && (LIT64( 0x8000000000000000 ) <= ((bits64) ( a.low<<1 ))); #else bits64 aLow;