This is the mail archive of the
mailing list for the GCC project.
Re: fast-math optimization question
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>, Steve Ellcey <sellcey at mips dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, Andrew Pinski <pinskia at gmail dot com>, GCC Mailing List <gcc at gcc dot gnu dot org>, Richard Biener <richard dot guenther at gmail dot com>
- Date: Fri, 10 Oct 2014 16:22:20 +0200
- Subject: Re: fast-math optimization question
- Authentication-results: sourceware.org; auth=none
- References: <10940e4b-0c5c-4a2a-9432-6385e9590fb4 at BAMAIL02 dot ba dot imgtec dot org> <CA+=Sn1mkOCmPxPmn-RYkE+CJBrQ=8U7O07RUj8wwc6KyuXzrJQ at mail dot gmail dot com> <1412879523 dot 28410 dot 133 dot camel at ubuntu-sellcey> <Pine dot LNX dot 4 dot 64 dot 1410091947001 dot 14581 at digraph dot polyomino dot org dot uk> <1412895334 dot 28410 dot 143 dot camel at ubuntu-sellcey> <20141010090752 dot GC10376 at tucnak dot redhat dot com> <20141010132715 dot GA22388 at ypig dot lip dot ens-lyon dot fr>
On Fri, Oct 10, 2014 at 3:27 PM, Vincent Lefevre <firstname.lastname@example.org> 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 <email@example.com> - Web: <https://www.vinc17.net/>
> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)