https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117393
Bug ID: 117393 Summary: Consider inlining memcmp(a, b, small constant)==0 on -Os Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: blubban at gmail dot com Target Milestone: --- int square(char* a, char* b) { return !__builtin_memcmp(a, b, 4); } -Os Expected: square(char*, char*): mov eax, DWORD PTR [rsi] cmp DWORD PTR [rdi], eax sete al movzx eax, al ret Actual: square(char*, char*): push rax mov edx, 4 call memcmp pop rdx test eax, eax sete al movzx eax, al ret It is inlined for sizes 0 and 1, but I'd expect 2, 4, 8 and 16 to be inlined as well. https://godbolt.org/z/7WEzWT6se