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]
Other format: [Raw text]

RE: Sine and Cosine Accuracy


----Original Message----
>From: Scott Robert Ladd
>Sent: 26 May 2005 19:09

> Dave Korn wrote:
>>   Well, as long as they're under the control of a flag that also makes it
>> clear that they are *also* unsafe math optimisations, I wouldn't object.
> 
> But they are *not* unsafe for *all* applications.

  Irrelevant; nor are many of the other things that are described by the
term unsafe.

  In fact they are often things that may be safe on one occasion, yet not on
another, even within one single application.  Referring to something as
"unsafe" doesn't mean it's *always* unsafe, but referring to it as safe (or
implying that it is by contrast with an option that names it as unsafe)
*does* mean that it is *always* safe.

> An ignorant user may not understand the ramifications of "unsafe" math
> -- however, the current documentation is quite vague as to why these
> optimizations are unsafe, and people thus become paranoid and avoid
> -ffast-math when it would be to their benefit.

  Until they get sqrt(-1.0) returning a value of +1.0 with no complaints, of
course....

  But yes: the biggest problem here that I can see is inadequate
documentation.

> First and foremost, GCC should conform to standards. *However*, I see
> nothing wrong with providing additional capability for those who need
> it, without combining everything "unsafe" under one umbrella.

  That's exactly what I said up at the top.  Nothing wrong with having
multiple unsafe options, but they *are* all unsafe.

>> But you can't just replace a call to the ANSI C 'sin' function with an
>> invocation of the x87 fsin intrinsic, because they aren't the same, and
>> the intrinsic is non-ansi-compliant.
> 
> Nobody said they were.

  Then any optimisation flag that replaces one with the other is, QED,
unsafe.

  Of course, if you went and wrote a whole load of builtins, so that with
your new flag in effect "sin (x)" would translate into a code sequence that
first uses fmod to reduce the argument to the valid range for fsin, I would
no longer consider it unsafe.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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