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

            Bug ID: 100046
           Summary: compare with itself
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luc.vanoostenryck at gmail dot com
  Target Milestone: ---

Created attachment 50569
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50569&action=edit
compare with itself

The attached file reproduced here:

int b3_06(int x, int y, int z) {
  int a = (x | z) ^ (y | z);
  int b = (x ^ y) & ~z;
  return a == b;
}

The generated assembly for for arm64 is:
    b3_06:
        eor     w3, w1, w0
        bic     w3, w3, w2
        cmp     w3, w3
        cset    w0, eq
        ret

So, GCC is able to see that both expressions are equivalent. Nice.
But then there is this compare with itself :(

The problem seems to exist forever on all targets (see
https://gcc.godbolt.org/z/qrYWsznof ).

Reply via email to