https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121595
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |easyhack --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Matteo Nicoli from comment #2) > This optimization must still be available when using the -ffast-math option, > right? No, just -fno-trapping-math is enough to be able to optimize away the `+0.0`. Basically `a+0.0` can cause a trap and currently GCC's default is trapping-math. The reason why `fabs(a+0.0)` can be optimized to just `fabs(a)` is because while `a+0.0` might change the sign; it is ignored with fabs as fabs will always zero out the sign bit. Note also `copy_sign(a+0.0, b)` can also be optimized to just `copy_sign(a, b)` for similar reasons (that is the sign bit of `a+0.0` is ignored so the `+0.0` part can be dropped).