https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104610
Bug ID: 104610
Summary: memcmp () == 0 can be optimized better for avx512f
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: x86_64-linux-gnu
Take:
bool f(char *a)
{
char t[] = "0123456789012345678901234567890";
return __builtin_memcmp(a, &t[0], sizeof(t)) == 0;
}
----- CUT ----
GCC does this via branches and compares but clang/LLVM does:
vmovdqu (%rdi), %ymm0
vpxor .LCPI0_0(%rip), %ymm0, %ymm0
vptest %ymm0, %ymm0
sete %al
vzeroupper