title: Why would < be slower than <=? [C]
body: <p>Naturally, I've assumed the &lt; and &lt;= operators run at the same speed (<a href="https://stackoverflow.com/questions/12135518/is-faster-than">per Jonathon Reinhart's logic, here</a>). Recently, I decided to test that assumption, and I was a little surprised by my results.</p>
  
  <p>I know, for most modern hardware, this question is purely academic, so had to write test programs that looped about 1 billion times (to get any minuscule difference to add up to more acceptable levels). The programs were as basic as possible (to cut out all possible sources of interference).</p>
  
  <p><strong>lt.c:</strong></p>
  
  <pre><code>int main() {
      for (int i = 0; i &lt; 1000000001; i++);
  
      return 0;
  }
  </code></pre>
  
  <p><strong>le.c:</strong></p>
  
  <pre><code>int main() {
      for (int i = 0; i &lt;= 1000000000; i++);
  
      return 0;
  }
  </code></pre>
  
  <p>They were compiled and run on a <em>Linux VirtualBox 3.19.0-18-generic #18-Ubuntu x86_64</em> installation, using GCC with the <em>-std=c11</em> flag set.</p>
  
  <p>The average time for lt.c's binary was:</p>
  
  <pre><code>real    0m2.404s
  user    0m2.389s
  sys 0m0.000s
  </code></pre>
  
  <p>The average time for le.c was:</p>
  
  <pre><code>real    0m2.397s
  user    0m2.384s
  sys 0m0.000s
  </code></pre>
  
  <p>The difference is small, but I couldn't get it to go away or reverse no matter how many times I ran the binaries.</p>
  
  <ul>
  <li>I made the comparison value in the for-loop of lt.c one larger than le.c (so they'd both loop the same number of times). Was this somehow a mistake?</li>
  <li>According the answer in <a href="https://stackoverflow.com/questions/12135518/is-faster-than">Is &lt; faster than &lt;=?</a>, <code>&lt;</code> compiles to <code>jge</code> and <code>&lt;=</code> compiles to <code>jg</code>. That was dealing with if statements rather than a for-loop, but could this still be the reason? Could the execution of <code>jge</code> take slightly longer than <code>jg</code>? <em>(I think this would be ironic since that would mean moving from C to ASM inverts which one is the more complicated instruction, with lt in C translating to gte in ASM and lte to gt.)</em></li>
  <li>Or, is this just so hardware specific that different x86 lines or individual chips may consistently show the reverse trend, the same trend, or no difference?</li>
  </ul>