double f(double x){ double y=-x; return __builtin_fabs(y); } The negation doesn't disappear, even at -Ofast, I still see both "xor" and "and" in the asm. (I don't think this optimization requires any unsafe math option, but I am not completely sure about the trapping behavior) Note that if I write __builtin_fabs(-x), the negation is removed before it has a chance to appear in a dump.
Related to or a dup of bug 16107.
Thanks, I had missed that one. ABS_EXPR is a bit special in that it has its own tree code, instead of appearing as a call to a builtin function, but the issue is the same indeed, the optimization is there but can never be applied. *** This bug has been marked as a duplicate of bug 16107 ***
Reopening since this is not a dup of that bug.
But it was fixed in GCC 5.0.