This is the mail archive of the gcc@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]

Re: FWD: FLOATING-POINT CONSISTENCY, -FFLOAT-STORE, AND X86


On Tue, 15 Dec 1998 11:12:01 -0700, Jeffrey A Law wrote:

  For integer, we need to know where the parens are to preserve integer overflow
  semantics in languages like Ada for similar transformations

I'd like to comment on this issue for Ada, and I'll explain what the current
situation is in GNAT and how (small?) compiler changes could improve efficiency 
of overflow checking.

Currently overflow checking is not done by default in GNAT (GNU Ada95 compiler).
To be fully standards conforming you need to run the compiler with the -gnato 
flag which enables these checks. The reason these checks are disabled is that 
they are inefficient, at least on 32-bit targets.

The compiler does all arithmetic that needs to be checked for overflows using a
wider type. Regular 32-bit integers are calculated using 64-bits. To get efficient
overflow checks, the compiler should be able to take advantage of overflow
bits in the status register and raise an exception when an overflow is
detected. This would be a place where the backend could help, although I don't
know exactly how this should be implemented.

Reordering integer additions is fine for Ada-95, as exceptions do not need 
to be exact as long as they occur in the same block. It is also allowed to
not raise an exception at all if the final result is mathematically correct,
even if intermediate values would have overflowed. Also when some operation
would have no external effect in the absense of checks, the compiler is allowed
to remove the checks and as a result usually is able to remove the operation
as well.

With checks off, the behavior in GNAT is the same as with C. Formally, it
would still be allowed to detect overflows or range checks and raise an
exception. Suppressing checks only means that the implementation should
not impose extra overhead because of the checks. 

Regards,
   Geert

PS. This description is informal, for the exact details see the Ada RM.
    (ISO/IEC/ANSI 8652:1995, http://www.adahome.com/Resources/refs/rm95.html)




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