title: Why doesn't GCC use partial registers?
body: <p>Disassembling <code>write(1,"hi",3)</code> on linux, built with <code>gcc -s -nostdlib -nostartfiles -O3</code> results in:</p>
  
  <pre><code>ba03000000     mov edx, 3 ; thanks for the correction jester!
  bf01000000     mov edi, 1
  31c0           xor eax, eax
  e9d8ffffff     jmp loc.imp.write
  </code></pre>
  
  <p>I'm not into compiler development but since every value moved into these registers are constant and known compile-time, I'm curious why doesn't gcc uses <code>dl</code>, <code>dil</code>, and <code>al</code> instead.
  Some may argue that this feature won't make any difference in performance but there's a big difference in executable size between <code>mov $1, %rax =&gt; b801000000</code> and <code>mov $1, %al =&gt; b001</code> when we are talking about thousands of register accesses in a program. Not only small size if part of a software's elegance, it does have effect on performance. </p>
  
  <p>Can someone explain why did "GCC decide" that it doesn't matter?</p>