From: Julian Brown <julian@codesourcery.com>
To: binutils@sources.redhat.com
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, DJ Delorie <dj@redhat.com>,
Paul Brook <paul@codesourcery.com>
Subject: [PATCH, libiberty] Fix (biased) exponent = 0 case in floatformat_to_double
Date: Mon, 24 Apr 2006 20:49:00 -0000 [thread overview]
Message-ID: <444D1777.1070400@codesourcery.com> (raw)
[-- 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
next reply other threads:[~2006-04-24 18:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-24 20:49 Julian Brown [this message]
2006-04-25 0:04 ` DJ Delorie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=444D1777.1070400@codesourcery.com \
--to=julian@codesourcery.com \
--cc=binutils@sources.redhat.com \
--cc=dj@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=paul@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).