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

            Bug ID: 95424
           Summary: Failure to optimize division with numerator of 1
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

unsigned f(unsigned x)
{
    return 1 / x;
}

This can be optimized to `return (x == 1);`, and for `int` to `return
(unsigned)(x + 1) < 3 ? x : 0;`. This transformation is done by LLVM, but not
by GCC.

Reply via email to