4 ms·
gcc -O2, clang, and icc all produce the sequence: is_even(int): mov eax, edi not eax and eax, 1 ret I am far from a x86 expert, bu
by Hello71 8y ago
gcc -O2, clang, and icc all produce the sequence:
is_even(int):
mov eax, edi
not eax
and eax, 1
ret
I am far from a x86 expert, but I assume this version avoids contention on the flags registers and increases pipelining.
edit: my mistake, icc and clang produce the equivalent sequence "not edi; and edi, 1; mov eax, edi; ret".