[Bug math/19465] Wrong code with -Os
joseph at codesourcery dot com
sourceware-bugzilla@sourceware.org
Thu Jan 14 21:08:00 GMT 2016
https://sourceware.org/bugzilla/show_bug.cgi?id=19465
--- Comment #5 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Thu, 14 Jan 2016, hjl.tools at gmail dot com wrote:
> With -Os,
>
> /* Ensure correct sign of exact 0 + 0. */
> if (__glibc_unlikely ((x == 0 || y == 0) && z == 0))
> return x * y + z;
>
> causes FE_INEXACT:
Those operations are obviously exact if the conditional holds. Do you
mean that the multiplication or addition are getting executed
unconditionally (moved before the if), even though they are conditional in
the source code? If so, a math_opt_barrier call inside the if should be
able to prevent that: "x = math_opt_barrier (x);".
The addition has to happen before the libc_feholdexcept_setround (&env,
FE_TONEAREST) call, because it has to happen in the original rounding mode
to get the correct sign of a zero result.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list