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

            Bug ID: 102580
           Summary: Failure to optimize signed division to unsigned
                    division when dividend can't be negative
           Product: gcc
           Version: 12.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: ---

int f(int x) {
  if (x < 0) 
    __builtin_abort();
  return x/3;
}

The `return` statement can be optimized to `return (unsigned)x/3;`. This
optimization is done by LLVM, but not by GCC.

Reply via email to