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

--- Comment #3 from Petr Skocik <pskocik at gmail dot com> ---
Here's another example (which may be summarizing it more nicely)

struct a{ char _[4]; };
#include <string.h>
int cmp(struct a A, struct a B){ return !!memcmp(&A,&B,4); }

Expected x86-64 codegen (✓ for gcc -O2/-O3 and for clang -Os/-O2/-O3)           
        xor     eax, eax
        cmp     edi, esi
        setne   al
        ret

gcc -Os codegen:
        subq    $24, %rsp
        movl    $4, %edx
        movl    %edi, 12(%rsp)
        leaq    12(%rsp), %rdi
        movl    %esi, 8(%rsp)
        leaq    8(%rsp), %rsi
        call    memcmp
        testl   %eax, %eax
        setne   %al
        addq    $24, %rsp
        movzbl  %al, %eax
        ret

https://godbolt.org/z/G5eE5GYv4

Reply via email to