title: Why do alignment restrictions change the behaviour of clang while vectorising?
body: <p>Can anyone explain the behaviour of clang?</p>
  <pre><code>Array4Complex64 f1(Array4Complex64 a, Array4Complex64 b){
      return a * b;
  }
  </code></pre>
  <p>This function calculates for each element in a and b the complex product. I compiled it twice once with alignment restrictions on the type Array4Complex64 and once without. the results are the following:</p>
  <p>with alignment:</p>
  <pre><code>f1(Array4Complex64, Array4Complex64):               # @f1(Array4Complex64, Array4Complex64)
      push    rbp
      mov     rbp, rsp
      and     rsp, -32
      sub     rsp, 32
      mov     rax, rdi
      vmovapd ymm0, ymmword ptr [rbp + 80]
      vmovapd ymm1, ymmword ptr [rbp + 112]
      vmovapd ymm2, ymmword ptr [rbp + 16]
      vmovapd ymm3, ymmword ptr [rbp + 48]
      vmulpd  ymm4, ymm1, ymm3
      vfmsub231pd     ymm4, ymm0, ymm2        # ymm4 = (ymm0 * ymm2) - ymm4
      vmovapd ymmword ptr [rdi], ymm4
      vmulpd  ymm0, ymm3, ymm0
      vfmadd231pd     ymm0, ymm1, ymm2        # ymm0 = (ymm1 * ymm2) + ymm0
      vmovapd ymmword ptr [rdi + 32], ymm0
      mov     rsp, rbp
      pop     rbp
      vzeroupper
      ret
  </code></pre>
  <p>without:</p>
  <pre><code>f1(Array4Complex64, Array4Complex64):               # @f1(Array4Complex64, Array4Complex64)
      mov     rax, rdi
      vmovupd ymm0, ymmword ptr [rsp + 72]
      vmovupd ymm1, ymmword ptr [rsp + 104]
      vmovupd ymm2, ymmword ptr [rsp + 8]
      vmovupd ymm3, ymmword ptr [rsp + 40]
      vmulpd  ymm4, ymm1, ymm3
      vfmsub231pd     ymm4, ymm0, ymm2        # ymm4 = (ymm0 * ymm2) - ymm4
      vmovupd ymmword ptr [rdi], ymm4
      vmulpd  ymm0, ymm3, ymm0
      vfmadd231pd     ymm0, ymm1, ymm2        # ymm0 = (ymm1 * ymm2) + ymm0
      vmovupd ymmword ptr [rdi + 32], ymm0
      vzeroupper
      ret
  </code></pre>
  <p>The result is the same, but the addresses are calculated differently: once relative to rbp and once relative to rsp. It is not exclusive to multiplication and applies to any calculation. Is one version better than the other?</p>