https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94795
--- Comment #2 from Gabriel Ravier <gabravier at gmail dot com> --- Also, I can also provide this a very similar function for which such an optimization could be helpful : int f(int x) { return -(x == 0); } LLVM optimises that function to this : f(int): cmp edi, 1 sbb eax, eax ret Whereas GCC currently does f(int): xor eax, eax test edi, edi sete al neg eax ret instead (see also https://godbolt.org/z/5_bRCR)