<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Multiple moves compiled inefficiently"
   href="https://bugs.llvm.org/show_bug.cgi?id=32086">32086</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Multiple moves compiled inefficiently
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>drraph@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider:

double a[4], b[4], c[4];

void foo ()
{
  a[0] = c[0];
  a[1] = c[1];
  a[2] = c[0];
  a[3] = c[1];
  b[0] = c[2];
  b[1] = c[3];
  b[2] = c[2];
  b[3] = c[3];
}

clang compiles this with -O3 to:

foo:                                    # @foo
        mov     rax, qword ptr [rip + c]
        mov     qword ptr [rip + a], rax
        mov     rcx, qword ptr [rip + c+8]
        mov     qword ptr [rip + a+8], rcx
        mov     qword ptr [rip + a+16], rax
        mov     qword ptr [rip + a+24], rcx
        mov     rax, qword ptr [rip + c+16]
        mov     qword ptr [rip + b], rax
        mov     rcx, qword ptr [rip + c+24]
        mov     qword ptr [rip + b+8], rcx
        mov     qword ptr [rip + b+16], rax
        mov     qword ptr [rip + b+24], rcx
        ret

gcc on the other hand gives the more efficient:

foo:
        movapd  xmm1, XMMWORD PTR c[rip]
        movapd  xmm0, XMMWORD PTR c[rip+16]
        movaps  XMMWORD PTR a[rip], xmm1
        movaps  XMMWORD PTR a[rip+16], xmm1
        movaps  XMMWORD PTR b[rip], xmm0
        movaps  XMMWORD PTR b[rip+16], xmm0
        ret</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>