https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77407
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2016-08-30 CC| |rguenth at gcc dot gnu.org Ever confirmed|0 |1 Severity|normal |enhancement --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Full testcase(?) int foo (int c) { if (c != 0) c /= __builtin_abs (c); return c; } Possible "fix": (simplify (trunc_div @0 (abs @0)) (if (! TYPE_UNSIGNED (type) && TYPE_OVERFLOW_UNDEFINED (type)) (cond (lt @0 { build_zero_cst (type); }) { build_minus_one_cst (type); } { build_one_cst (type); }))) but eventually we should simply make __builtin_copysign also work on integers... Not sure if desirable also for _Complex int and vector int (both handled above). Need to double-check for non-truncating divisions. Similar testcase would be if (c != 0) c /= -c;