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

            Bug ID: 127735
           Summary: Better optimize integer comparisons with a common
                    factor
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gjl at gcc dot gnu.org
  Target Milestone: ---

When integer overflow is undefined, e.g. -fno-wrapv, in

char c;
void cmpar (int a, int b)
{
    if (3*a + 1 < 6*b + 4)
        c = 0;
}

the following optimization could be performed:

3*a + 1 < 6*b + 4
<=>  3*a < 6*b + 3       // (1)
<=>  a < 2*b + 1         // (2)

(1) is already done, but (2) is not.

Reply via email to