public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: vax double precision broken
@ 2002-06-03 12:35 John David Anglin
  0 siblings, 0 replies; 4+ messages in thread
From: John David Anglin @ 2002-06-03 12:35 UTC (permalink / raw)
  To: gcc; +Cc: pkoning

It's possible the emulator is broken for the vax.  Richard Henderson
changed vax.h on Jan. 9 to define REAL_ARITHMETIC.  Previously, the
compiler didn't use the emulator (you were supposed to hack vax.h
to use the emulator if you were building a cross compiler).

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: vax double precision broken
       [not found] <no.id>
@ 2002-06-01 17:01 ` Joe Buck
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Buck @ 2002-06-01 17:01 UTC (permalink / raw)
  To: Paul Koning; +Cc: gcc


> The single and double IEEE formats do indeed look similar to VAX F and
> G formats respectively, but they do NOT match.  There are three key
> differences: the halfwords are in the opposite order (sign bit is bit
> 31 in each case for IEEE); the exponent bias is one less -- 127 and
> 1023 for IEEE vs. 128 and 1024 for VAX; and the hidden high order bit
> is interpreted as the bit just to the left of the binary point (2**0)
> in IEEE rather than just to the right (2**-1) as in VAX.  (In
> addition, IEEE has both Inf and NaN, while DEC format only has NaN.
> And IEEE has denormals; DEC does not.)

There's a 4th difference: F-floating has the same exponent size as IEEE
single precision, but D-floating has the same number of exponent bits
as F-floating while IEEE doubles have more exponent bits.  (Conversion
from Vax-D to Vax-F is a simple matter of rounding off the mantissa, while
for IEEE, overflow can occur because the double precision type has greater
range).

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

* Re: vax double precision broken
  2002-05-29 16:01 Stephen L Moshier
@ 2002-06-01 12:36 ` Paul Koning
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Koning @ 2002-06-01 12:36 UTC (permalink / raw)
  To: gcc

Excerpt of message (sent 29 May 2002) by Stephen L Moshier:
> ...
> Regarding the question about single precision, the binary data structure
> that we produce matches what we found on three different vaxen
> at the time the emulator was written.  It is definitely _not_ the same
> as pdp-11 data structure.  From the beginning, vax offered a pdp-11
> emulation mode that gave you both single and double precision
> pdp-11 numbers; but that was not the default.  I am now speculating
> without having the books in front of me, but the default as I
> remember it gave you an IBM-compatible single precision that later was
> the basis of IEEE single precision format.  Vaxen go back to about 1979,
> while IEEE 754 was adopted in 1985.

I commented on this offline, but at Stephen's suggestion I'll repeat
it on the list.  Those of you with VAX expertise or, better yet, VAXen
to run stuff on, please look this over.  I'm in the process of
constructing a patch to real.c to fix the issues that Stephen raised
(working from the real.c cleanup that Roman has been doing) but it
sure would help to have this double-checked by others.

I have no explanation for observations that suggests VAX float is
different from PDP-11 float -- for "F" and "D" float, that is.  I
don't have access to VAX hardware, unfortunately.  I do have DEC
reference manuals, which have this to say:

1. VAX-11 Architecture Handbook, 1979 (I believe that's the first
edition of what PDP11s called "processor handbook" -- 11/780 only).

It describes only the original two float formats, F and D.  Page 9
says "Floating point values are stored using a signed 8-bit excess-128
exponent and a binary normalized fraction, using 4-byte and 8-byte
formats identical to those of the PDP-11."  And indeed the next page
shows diagrams identical to those in the PDP-11 Architecture Manual,
even going as far as to show 16-bit wide layouts.

2. VAX architecture reference manual (1987), page 7-9 shows the four
floating point formats, F, D, G, H.

Diagrams:

	31                16 15 14           7 6         0
	+-------------------+--+--------------+-----------+
	|     fraction      |S | exponent     | fraction  | :A
	+-------------------+--+--------------+-----------+
	F-floating data type

	31                16 15 14           7 6         0
	+-------------------+--+--------------+-----------+
	|     fraction      |S | exponent     | fraction  | :A
	+-------------------+--+--------------+-----------+
	|     fraction      |      fraction               | :A + 4
	+-------------------+-----------------------------+
	63                                               32
	D-floating data type

	31                16 15 14             4 3       0
	+-------------------+--+----------------+---------+
	|     fraction      |S |    exponent    |fraction | :A
	+-------------------+--+----------------+---------+
	|     fraction      |      fraction               | :A + 4
	+-------------------+-----------------------------+
	63                                               32
	G-floating data type

	31                16 15 14                       0
	+-------------------+--+--------------------------+
	|     fraction      |S |      exponent            | :A
	+-------------------+--+--------------------------+
	|     fraction      |      fraction               | :A + 4
	+-------------------+-----------------------------+
	|     fraction      |      fraction               | :A + 8
	+-------------------+-----------------------------+
	|     fraction      |      fraction               | :A + 12
	+-------------------+-----------------------------+
	127                                              96
	H-floating data type

(For F and D those are the same as in the earlier VAX-11 book, except
for presentation -- it is presented 32 bits at a time.)

In all cases, the fraction is normalized with the high order bit not
represented.  For F and D, the MSB of the fraction is bit 6.  For F,
the LSB is bit 16.  For D and G, it's bit 48.  For H, MSB is bit 31,
and LSB is bit 112.

Exponent is excess-128 for F and D, excess-1024 for G, and
excess-16384 for H.  In all cases, exponent field (as coded) == 0 is
used for representing float 0.0 if S is 0, and NaN if S is 1.

---
I just looked at my MIPS architecture manual, that being the closest
thing I have to a description of the IEEE float format.

The single and double IEEE formats do indeed look similar to VAX F and
G formats respectively, but they do NOT match.  There are three key
differences: the halfwords are in the opposite order (sign bit is bit
31 in each case for IEEE); the exponent bias is one less -- 127 and
1023 for IEEE vs. 128 and 1024 for VAX; and the hidden high order bit
is interpreted as the bit just to the left of the binary point (2**0)
in IEEE rather than just to the right (2**-1) as in VAX.  (In
addition, IEEE has both Inf and NaN, while DEC format only has NaN.
And IEEE has denormals; DEC does not.)

All that fits the data in www.netlib.org/port/Mach/r1mach.f: it shows
VAX value for Log10(2) as 0x209B3F9A vs. IEEE as 0x3E9A209B, so the
fraction is the same (1A209B as stored, i.e., 90209B if you include
the hidden bit) and the exponents differ by two, which is 1 due to the
different bias and one due to the different placement of the binary
point. 

     paul



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

* vax double precision broken
@ 2002-05-29 16:01 Stephen L Moshier
  2002-06-01 12:36 ` Paul Koning
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen L Moshier @ 2002-05-29 16:01 UTC (permalink / raw)
  To: gcc


While checking the ASM_OUTPUT_DOUBLE macros I glossed over the vax
because I thought I knew it.  The microvax at FSF went to Valhalla
somewhere around gcc-2.6, however, so I had begun to lose track then.
What seems to have happened later is that a support for switchable
D or G format double precision was installed.

Since our emulation is not switchable at present (due to sundry items
like TARGET_FLOAT_FORMAT being macros instead of variables), the
REAL_ARITHMETIC feature has to be turned off.  That has been made
impossible.  Also the format switching depended on a printf statement that
used to be in the ASM_OUTPUT_DOUBLE macro that no longer exists.
The gcc command line switch flags are still there, but nothing much will
happen if you exercise them.  Therefore vax is now broken, in the same way
that alpha and convex are broken.

Regarding the question about single precision, the binary data structure
that we produce matches what we found on three different vaxen
at the time the emulator was written.  It is definitely _not_ the same
as pdp-11 data structure.  From the beginning, vax offered a pdp-11
emulation mode that gave you both single and double precision
pdp-11 numbers; but that was not the default.  I am now speculating
without having the books in front of me, but the default as I
remember it gave you an IBM-compatible single precision that later was
the basis of IEEE single precision format.  Vaxen go back to about 1979,
while IEEE 754 was adopted in 1985.


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

end of thread, other threads:[~2002-06-03 18:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-03 12:35 vax double precision broken John David Anglin
     [not found] <no.id>
2002-06-01 17:01 ` Joe Buck
  -- strict thread matches above, loose matches on Subject: below --
2002-05-29 16:01 Stephen L Moshier
2002-06-01 12:36 ` Paul Koning

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).