Hacker News new | past | comments | ask | show | jobs | submit login

I highly doubt it. That’s 1:1

  test eax, 1
  ; use result



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".




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: