https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86732
--- Comment #1 from Antony Polukhin <antoshkka at gmail dot com> --- Probably a more fair example< without taking an address of a reference: static const int* get_if(const int* v) { if (v && *v == 0) return v; return nullptr; } int example(const int* a) { return *get_if(a); } GCC produces the same suboptimal assembly: _Z7examplePKi: test rdi, rdi je .L2 mov eax, DWORD PTR [rdi] test eax, eax jne .L2 xor eax, eax ret _Z7examplePKi.cold.0: .L2: mov eax, DWORD PTR ds:0 ud2 While Clang just generates: _Z7examplePKi: # @_Z7examplePKi mov eax, dword ptr [rdi] ret