title: Why does GCC include an "empty" XOR
body: <p>I have following piece of code:</p>
  <pre class="lang-c prettyprint-override"><code>typedef struct {
          int x;
          int y;
          int z;
          int w;
  } s32x4;
  
  s32x4
  f() {
          s32x4 v;
          v.x = 0
  
          return v;
  }
  </code></pre>
  <p>which generates (gcc -O2):</p>
  <pre><code>f:
          xor     eax, eax
          xor     edx, edx          ; this line is questionable
          ret
  </code></pre>
  <p>where clang outputs (clang -O2):</p>
  <pre><code>f:                                      # @f
          xor     eax, eax
          ret
  </code></pre>
  <h1>Questions</h1>
  <ul>
  <li>Is there a reason why <code>GCC</code> inserts an <code>XOR</code> there?</li>
  <li>If there isn't a good reason for it: can I somehow get rid of it?</li>
  </ul>
  <h3>Note</h3>
  <ul>
  <li>In case you want to play with the example: <a href="https://godbolt.org/z/74YcY63sE" rel="nofollow noreferrer">https://godbolt.org/z/74YcY63sE</a></li>
  </ul>