This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [gfortran] Fix NEAREST constant folder


Steve Kargl wrote:
>>IOW we can't get compile-time arithmetic right with mpfr?  This is very
>>unfortunate.  (Another possible application for NEAREST(0.,1.) is to check for
>>the existence of denormals: NEAREST(0.,1.) < TINY(0.) should be true iff the
>>machine representation supports subnormals)
> 
> Well, I've spent some time looking through the standard, and have
> come up empty.  The definition of NEAREST() in 13.14.76 clearly
> states that it returns "the nearest different machine representable
> number in a given direction".  AFAIK, the standard does not define
> the meaning of "machine representable number".  We also have from
> 13.14
> 
>    A program is prohibited from invoking an intrinsic procedure
>    under circumstances where a value to be returned in a subroutine
>    argument or function result is outside the range of values
>    representable by objects of the specified type and type parameters.
> 
> which suggests that the nearest(0,1) should return tiny().  Time to 
> expose my ignorance on c.l.f. :-)

Apart from the specific question how NEAREST is defined, compile time
arithmetic should yield the same results as target arithmetic.  Which in this
case either means disabling subnormals in compiled binaries -- which I'm not
even sure is possible --, or supporting them in the compiler.  I think people
would kill us, if we did the former :-)

- Tobi


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