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

            Bug ID: 77407
           Summary: Optimize integer i / abs (i) into the sign of i
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fw at gcc dot gnu.org
  Target Milestone: ---

I found this gem in some glibc test case:

  if (c != 0)
    c /= abs (c);

This could turn into:

  if (c < 0)
    c = -1;
  else if (c > 0)
    c = 1;

This would eliminate the division and also paper of the bug (the unexpected 1
result for INT_MIN).

Reply via email to