From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16719 invoked by alias); 24 Apr 2006 18:23:52 -0000 Received: (qmail 16614 invoked by uid 22791); 24 Apr 2006 18:23:51 -0000 X-Spam-Check-By: sourceware.org Received: from intranet.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.6) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 24 Apr 2006 18:23:47 +0000 Received: (qmail 24157 invoked from network); 24 Apr 2006 18:23:45 -0000 Received: from unknown (HELO ?10.1.1.7?) (julian@127.0.0.2) by mail.codesourcery.com with ESMTPA; 24 Apr 2006 18:23:45 -0000 Message-ID: <444D1777.1070400@codesourcery.com> Date: Mon, 24 Apr 2006 20:49:00 -0000 From: Julian Brown User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) MIME-Version: 1.0 To: binutils@sources.redhat.com CC: GCC Patches , DJ Delorie , Paul Brook Subject: [PATCH, libiberty] Fix (biased) exponent = 0 case in floatformat_to_double Content-Type: multipart/mixed; boundary="------------060001090404030605070705" Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00326.txt.bz2 This is a multi-part message in MIME format. --------------060001090404030605070705 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1049 Hi, This patch fixes a case in floatformat_to_double, as used in binutils for disassembling floats for m68k (and soon ARM also). The failure mode was as follows: the exponent was tested for zero after biasing, which is true for floating point values 1.0 <= value < 2.0. Such values took a code path intended for denormals, with the effect of causing them to always produce the value 1.0 (or, perhaps, very close to 1.0). This patch only processes values as denormal when special_exponent is true. Tested with "make check" on CSL's current binutils branch, with targets arm-none-eabi and --enable-targets=all (the ARM version includes a new testcase which exercises some floating-point values). The patch applies cleanly on GCC head's libiberty too, though I've not explicitly tested it there. I suspect it'll also apply on binutils head. OK to apply on src and gcc head, or is there any more testing I should do? Cheers, Julian ChangeLog (libiberty): * floatformat.c (floatformat_to_double): Fix (biased) exponent=0 case. --------------060001090404030605070705 Content-Type: text/plain; name="libiberty-floatformat-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="libiberty-floatformat-1" Content-length: 841 Index: floatformat.c =================================================================== RCS file: /cvs/src/src/libiberty/floatformat.c,v retrieving revision 1.19 diff -c -p -r1.19 floatformat.c *** floatformat.c 12 Feb 2006 15:54:25 -0000 1.19 --- floatformat.c 24 Apr 2006 17:47:42 -0000 *************** floatformat_to_double (const struct floa *** 394,400 **** /* Handle denormalized numbers. FIXME: What should we do for non-IEEE formats? */ ! if (exponent == 0 && mant != 0) dto += ldexp ((double)mant, (- fmt->exp_bias - mant_bits --- 394,400 ---- /* Handle denormalized numbers. FIXME: What should we do for non-IEEE formats? */ ! if (special_exponent && exponent == 0 && mant != 0) dto += ldexp ((double)mant, (- fmt->exp_bias - mant_bits --------------060001090404030605070705--