This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

/target:458:alpha-dec-osf4: Denormal numbers work with -mieee


Number: 458
Category: target
Synopsis: [alpha Digital Unix 4] small number floating-point exception
Class: sw-bug
Arrival-Date: Thu Aug 10 00:46:00 PDT 2000
Originator: E. Krömer
Release: gcc version 2.95.2 19991024 and several older ones
Environment: system OSF1 V4.0 878 alpha (Digital Unix 4.0d)
compiler: gcc -v testi.c
Reading specs from /usr/gnu/lib/gcc-lib/alpha-dec-osf4.0d/2.8.1/specs
gcc version 2.8.1
...
Notes:
> multiplying a number of approx 1e-314 (should be 0, rounding errors)
> with another yields the error.
> everything > 1e-309 is ok
> everything < 1e-324 is ok (identical 0)
> core dumped in line of multiplication, * needs to be in
> a subroutine, same line in main doesn't give an error.
> Same code on Linux yields no problems
> funny: gdb 4.16 (alpha-dec-osf4.0) does very much the same:
> (gdb) p 2.0*1e-307
> $7 = 1.9999999999999998e-307
> (gdb) p 2.0*1e-308
> Erroneous arithmetic operation.
> (gdb) p 2.0*1e-323
> Erroneous arithmetic operation.
> (gdb) p 2.0*1e-324
> $8 = 0

Double values of magnitude between ~ 2e-308 and 1e-323 can be represented as
IEEE denormal numbers, which gcc supports when the -mieee flag is used.
Without -mieee, versions of the PR's test program  built with
gcc 2.95.2, 2.95.3-test5 or 3.0 20010521 (prerelease) all cause a
`Floating point exception'. Built with -mieee, all work.

Alpha Architecture Handbook  Order Number: EC-QD2KC-TE
Revision/Update Information: This is Version 4 of the Alpha
Architecture Handbook.

Page 2-8:
...

The T_floating load instruction performs no bit reordering on input, nor
does it perform checking of the input data.

The T_floating store instruction performs no bit reordering on output.
This instruction does no checking of the data; the preceding operation
should have specified a T_floating result.

A T_floating datum is specified by its address A, the address of the
byte containing bit 0. The form of a T_floating datum is sign magnitude
with bit 63 the sign bit, bits <62:52> an excess-1023 binary exponent,
and bits <51:0> a 52-bit fraction.
The value (V) of a T_floating number is inferred from its constituent
sign (S), exponent (E), and fraction (F) fields as follows:

. If E=2047 and F<>0, then V is NaN, regardless of S.
. If E=2047 and F=0, then V = (-1)**S x Infinity.
. If 0 < E < 2047, then V = (-1)**S x 2**(E-1023) x (1.F).
. If E=0 and F<>0, then V = (-1)**S x 2**(-1022) x (0.F).
. If E=0 and F=0, then V = (-1)**S x 0 (zero).

Floating-point operations on T_floating numbers may take an arithmetic
exception for a variety of reasons, including invalid operations,
overflow, underflow, division by zero, and inexact results.
--

>From the above, the miminum magnitude of a T_floating number (a double)
is 2**-1022 for a `normal' number. Denormal numbers can have smaller
magnitudes with leading zeros in the fraction down to 2**(-1022-51)
= 2**-1073.
=> Smallest magnitude   normal number is 2**-1022 ~= 2.225074e-308
=> Smallest magnitude denormal number is 2**-1073 ~= 9.881313e-324

File: gcc.info,  Node: DEC Alpha Options
...
`-mieee'
     The Alpha architecture implements floating-point hardware
     optimized for maximum performance.  It is mostly compliant with
     the IEEE floating point standard.  However, for full compliance,
     software assistance is required.  This option generates code fully
     IEEE compliant code *except* that the INEXACT FLAG is not
     maintained (see below).  If this option is turned on, the CPP
     macro `_IEEE_FP' is defined during compilation.  The option is a
     shorthand for: `-D_IEEE_FP -mfp-trap-mode=su -mtrap-precision=i
     -mieee-conformant'.  The resulting code is less efficient but is
     able to correctly support denormalized numbers and exceptional
     IEEE values such as not-a-number and plus/minus infinity.  Other
     Alpha compilers call this option `-ieee_with_no_inexact'.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]