Floating point optimizations

me22 me22.ca@gmail.com
Sat Apr 5 21:26:00 GMT 2008


On Sat, Apr 5, 2008 at 9:06 AM, NightStrike <nightstrike@gmail.com> wrote:
>  Wait, so are things like "c - (c - a)" optimized down to "a" or not?  I
>  use a lot of that in very time-intensive c++ code.
>

I think only if you tell it to be loose with requirements for applying
floating-point math optimizations (-ffast-math and related), since
DBL_MAX - (DBL_MAX-1) is, to the best of my knowledge, 0 --- not 1 ---
in IEEE math.

On the other hand, I managed to get >1 by adding DBL_EPSILON/10 to 1.0
repeatedly (though only on 1 of 4 computers on which I tried it) so my
intuitions could all be wrong.



More information about the Gcc-help mailing list