title: Complex compiler output for simple constructor
body: <p>I have a struct X with two 64-bit integer members, and a constructor:</p>
  
  <pre><code>struct X
  {
      X(uint64_t a, uint64_t b)
      {
          a_ = a; b_ = b;
      }
  
      uint64_t a_, b_;
  };
  </code></pre>
  
  <p>When I look at the compiler output (x86-64 gcc 8.3 and x86-64 clang 8.0.0, on 64-bit Linux), with no optimizations enabled, I see the following code for the constructor.</p>
  
  <p>x86-64 gcc 8.3:</p>
  
  <pre><code>X::X(unsigned long, unsigned long):
      push    rbp
      mov     rbp, rsp
      mov     QWORD PTR [rbp-8], rdi
      mov     QWORD PTR [rbp-16], rsi
      mov     QWORD PTR [rbp-24], rdx
      mov     rax, QWORD PTR [rbp-8]
      mov     QWORD PTR [rax], 0
      mov     rax, QWORD PTR [rbp-8]
      mov     QWORD PTR [rax+8], 0
      mov     rax, QWORD PTR [rbp-8]
      mov     rdx, QWORD PTR [rbp-16]
      mov     QWORD PTR [rax+8], rdx
      mov     rax, QWORD PTR [rbp-8]
      mov     rdx, QWORD PTR [rbp-24]
      mov     QWORD PTR [rax], rdx
      nop
      pop     rbp
      ret
  </code></pre>
  
  <p>x86-64 clang 8.0.0:</p>
  
  <pre><code>X::X(unsigned long, unsigned long):
      push    rbp
      mov     rbp, rsp
      mov     qword ptr [rbp - 8], rdi
      mov     qword ptr [rbp - 16], rsi
      mov     qword ptr [rbp - 24], rdx
      mov     rdx, qword ptr [rbp - 8]
      mov     qword ptr [rdx], 0
      mov     qword ptr [rdx + 8], 0
      mov     rsi, qword ptr [rbp - 16]
      mov     qword ptr [rdx + 8], rsi
      mov     rsi, qword ptr [rbp - 24]
      mov     qword ptr [rdx], rsi
      pop     rbp
      ret
  </code></pre>
  
  <p>Does anyone know why the output is so complex?  I would have expected two simple "mov" statements, even with no optimizations enabled.</p>