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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2019-04-25
          Component|c++                         |middle-end
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We should simplify this to

 a = copysignf (1.0, a);

I guess.

Confirmed on trunk with a C testcase:

int main() {
    float a = 0;
    __builtin_printf ("%f\n", a);
    a = (a > 0) ? 1.0 : -1.0;
    __builtin_printf ("%f\n", a);
    return 0;
}

And indeed .original already shows (but only with -ffinite-math-only
because of a being possibly NaN).

    float a = 0.0;
  __builtin_printf ((const char *) "%f\n", (double) a);
  a = __builtin_copysignf (1.0e+0, a);
  __builtin_printf ((const char *) "%f\n", (double) a);

wrong sign for the copysign transform for zero.

Reply via email to