https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121595

--- Comment #4 from Matteo Nicoli <matteo.nicoli001 at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> (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).

Thank you Andrew

Reply via email to