public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, libiberty] Fix (biased) exponent = 0 case in floatformat_to_double
@ 2006-04-24 20:49 Julian Brown
  2006-04-25  0:04 ` DJ Delorie
  0 siblings, 1 reply; 2+ messages in thread
From: Julian Brown @ 2006-04-24 20:49 UTC (permalink / raw)
  To: binutils; +Cc: GCC Patches, DJ Delorie, Paul Brook

[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

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.

[-- Attachment #2: libiberty-floatformat-1 --]
[-- Type: text/plain, Size: 841 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, libiberty] Fix (biased) exponent = 0 case in floatformat_to_double
  2006-04-24 20:49 [PATCH, libiberty] Fix (biased) exponent = 0 case in floatformat_to_double Julian Brown
@ 2006-04-25  0:04 ` DJ Delorie
  0 siblings, 0 replies; 2+ messages in thread
From: DJ Delorie @ 2006-04-25  0:04 UTC (permalink / raw)
  To: julian; +Cc: binutils, gcc-patches


> ChangeLog (libiberty):
> 
>      * floatformat.c (floatformat_to_double): Fix (biased) exponent=0
>      case.

Ok.  Please note that libiberty patches must be committed to gcc
before, or at least at the same time as, binutils.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-04-24 18:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-24 20:49 [PATCH, libiberty] Fix (biased) exponent = 0 case in floatformat_to_double Julian Brown
2006-04-25  0:04 ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).