weird optimization in sin+cos, x86 backend

Robert Dewar dewar@adacore.com
Sat Feb 4 12:15:00 GMT 2012


On 2/4/2012 7:00 AM, Andreas Schwab wrote:
> Vincent Lefevre<vincent+gcc@vinc17.org>  writes:
>
>> Wrong. 53 bits of precision. And 10^22 is the last power of 10
>> exactly representable in double precision (FYI, this example has
>> been chosen because of this property).
>
> But it is indistinguishable from 10^22+pi.  So both -0.8522008497671888
> and 0.8522008497671888 are correct results, or anything inbetween.

I don't see that 10**22 is a well defined exactly represented value, 
whose sin/cos values are exactly well defined, the fact that
10**22+pi cannot be represented exactly does not change that.

I agree that if you write a literal for a value which cannot be
represented exactly, there may be some ambiguity, as Vincent
suggests (you can't tell if it is just a request for a close
value, or very specifically a request for the correctly rounded
machine number). But if you write a literal that can be represented
exactly, then it is perfectly reasonable to expect trig functions
to give the proper result, which is unambiguous in this case.
>
> Andreas.
>



More information about the Gcc mailing list