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

            Bug ID: 104018
           Summary: Comparison against 0 propagates into other statement
                    causing no-CSE from happening
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
int f(unsigned int a, unsigned int b) {
    if (a > 0) {
        return a == b;
    } else {
        return a == b;
    }
}
int f2(unsigned int a, unsigned int b) {
    if (a > 1) {
        return a == b;
    } else {
        return a == b;
    }
}

They should produce the same results but don't currently as in the first case
the >0 is turned into != 0 and then the 0 is propagated into the comparison and
then the comparison in the other BBSs are not able to be CSE'ed with the other
one.

Reply via email to