You might not like it, but this is what peak compiler performance looks like.
@ela this stumped me until I saw clang decides to return bool in al, not eax, for some reason.
@mirabilos @ela does "and al,1" clear the upper bits?
@waldi @ela only seven of them
@mirabilos @waldi To be unfathomably pedantic, that would be all of them for al.
@ela @waldi yes, but it using only al ipv eax for the return value strikes me as interesting ABI choice.
@mirabilos @ela Ah, because _Bool is defined as 8bit value where only bit 0 matters, bits 1 to 7 are set to 0 and 8 to 63 are undefined.
@waldi @ela except for actual storage (where one bit would be better in structs for example), blowing it up to the full 32 bits would reduce the number of instructions executed overall in typical programs (and incidentally even the code size)
@mirabilos @waldi Well, it's what the spec says.
@ela @waldi I admit only vague familiarity with the psABI for amd64 (normally preferring i386), and specifically not that they chose a (surprising, to me) representation for booleans