public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/93265] memcmp comparisons of structs wrapping a primitive type not as compact/efficient as direct comparisons of the underlying primitive type under -Os
[not found] <bug-93265-4@http.gcc.gnu.org/bugzilla/>
@ 2023-05-01 8:22 ` pskocik at gmail dot com
0 siblings, 0 replies; only message in thread
From: pskocik at gmail dot com @ 2023-05-01 8:22 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-01 8:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-93265-4@http.gcc.gnu.org/bugzilla/>
2023-05-01 8:22 ` [Bug tree-optimization/93265] memcmp comparisons of structs wrapping a primitive type not as compact/efficient as direct comparisons of the underlying primitive type under -Os pskocik at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).