[Bug rtl-optimization/95891] New: Missing optimization

jm at bourguet dot org gcc-bugzilla@gcc.gnu.org
Thu Jun 25 08:38:57 GMT 2020


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

            Bug ID: 95891
           Summary: Missing optimization
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jm at bourguet dot org
  Target Milestone: ---

I'm sorry, this is perhaps not the correct component but my knowledge of gcc
internals does not allow me to do more than guess.

For all version of gcc I've tried, the following code:

struct point {
    int x, y;
};

bool f(point a, point b) {
    return a.x == b.x && a.y == b.y;
}

bool f(unsigned long long a, unsigned long long b) {
    return a == b;
}

is compiled to

f(point, point):
        xor     eax, eax
        cmp     edi, esi
        je      .L5
        ret
.L5:
        sar     rdi, 32
        sar     rsi, 32
        cmp     edi, esi
        sete    al
        ret
f(unsigned long long, unsigned long long):
        cmp     rdi, rsi
        sete    al
        ret

I'd expect f(point, point) to have the same assembly as f(unsigned long long,
unsigned long long).

Yours,

-- Jean-Marc Bourguet


More information about the Gcc-bugs mailing list