This is the mail archive of the 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: fast-math optimization question

On Fri, Oct 10, 2014 at 3:27 PM, Vincent Lefevre <> wrote:
> On 2014-10-10 11:07:52 +0200, Jakub Jelinek wrote:
>> Though, is such optimization desirable even for fast-math?
> I wonder whether fast-math has a well-defined spec, but it should be
> noted that because of possible cancellations, even if the final result
> is a float, it may be better to keep intermediate results in double
> if the user has used double types (explicitly or implicitly via a
> function that returns a double). For instance, if x is a double,
> (float) sin(x) and (float) sin((float) x) can give very different
> results if x is large compared to the period (2*pi).

I think the only case handled right now is x being float and
(float) sin ((double) x) being called.  I think for that case the
demotion is fine (and it is a common mistake that people don't know
about the 'f' variants and expect sin to behave as type-generic function).


> --
> Vincent LefÃvre <> - Web: <>
> 100% accessible validated (X)HTML - Blog: <>
> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

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