title: Difference between "or eax,eax" and "test eax,eax"
body: <p>What's the difference between <code>or eax,eax</code> and <code>test eax,eax</code>? I've seen different compilers produce both for the same comparison and as far as documentation goes they do exactly the same thing, so I'm wondering why they don't all use <code>test eax,eax</code>. Thinking about it <code>and eax,eax</code> would set the flags in an identical fashion as either but I haven't seen it in either freepascal, delphi, or msVC++.</p>
  
  <p>I did compile some asm blocks in delphi and checked out the assembler source and all 3 forms are the exact same length in opcodes and also checked the intel performance PDF and it says they have the same latency and throughput.</p>
  
  <p>Edit:<br>
  The question is specifically about the difference between the specific cases <code>test eax,eax</code>, <code>or eax,eax</code> and <code>and eax,eax</code>. All 3 give completely identical results for registers, flags, opcode length, latency, throughput. And yet for testing if 0, if not zero, or if signed, some compilers will use <code>test eax,eax</code> while some use <code>or eax,eax</code>, and I was wondering why they aren't all using <code>test eax,eax</code> since it makes the code very slightly clearer.</p>
  
  <p>Edit2:<br>
  For reference I'm at home and only have and older msvc++ and Delphi here, but testing a variable if zero, msvc++ does <code>test eax,eax</code>, while Delphi does <code>or eax,eax</code>.</p>