<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 - Can't coalesce four consecutive byte loads into a single x86 mov"
   href="https://bugs.llvm.org/show_bug.cgi?id=33498">33498</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Can't coalesce four consecutive byte loads into a single x86 mov
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>justin.lebar@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mkuper@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider

unsigned foo(unsigned char* d) {
  return (static_cast<unsigned int>(d[0]) << 0) |
         (static_cast<unsigned int>(d[1]) << 8) |
         (static_cast<unsigned int>(d[2]) << 16) |
         (static_cast<unsigned int>(d[3]) << 24);
}

gcc 5.1+ compiles this as 

  mov     eax, DWORD PTR [rdi] 
  ret

but clang 4.0 -O2 naively does a series of shifts bitwise ORs:

        movzx   eax, byte ptr [rdi]
        movzx   ecx, byte ptr [rdi + 1]
        shl     ecx, 8
        or      ecx, eax
        movzx   edx, byte ptr [rdi + 2]
        shl     edx, 16
        or      edx, ecx
        movzx   eax, byte ptr [rdi + 3]
        shl     eax, 24
        or      eax, edx
        ret

I'll test on clang at HEAD in a few minutes once I get a build up and running.</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>