https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96271
Bug ID: 96271 Summary: Failure to optimize memcmp of doubles to avoid going through memory Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: gabravier at gmail dot com Target Milestone: --- bool f(double a, double b) { return memcmp(&a, &b, sizeof(double)) == 0; } With -O3, LLVM outputs this : f(double, double): movq rax, xmm0 movq rcx, xmm1 cmp rax, rcx sete al ret GCC outputs this: f(double, double): movsd QWORD PTR [rsp-8], xmm0 movsd QWORD PTR [rsp-16], xmm1 mov rax, QWORD PTR [rsp-16] cmp QWORD PTR [rsp-8], rax sete al ret