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

            Bug ID: 101754
           Summary: Missed fold for a/b*b
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: llvm at rifkin dot dev
  Target Milestone: ---

GCC is not optimizing the following (contrived) divisibility check
https://godbolt.org/z/1rEhYa8Ts.

bool foo(int a, int b) {
    return a/b*b == a;
}
bool bar(int a, int b) {
    return a%b == 0;
}

If GCC can fold a/b*b into a-a%b, it will be able to optimize properly the rest
of the way.

Reply via email to