<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 - Suboptimal vectorization"
   href="https://bugs.llvm.org/show_bug.cgi?id=47436">47436</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Suboptimal vectorization
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>#include<stdint.h>

uint8_t data[16];
 void test(unsigned i)
{
        unsigned j;
        for (j = 0; j < 16; j++)
                data[j] = (i + j) >> 8;
}

Clang -O3 -march=haswell:
test(unsigned int):                               # @test(unsigned int)
        lea     eax, [rdi + 12]
        vmovd   xmm0, eax
        lea     eax, [rdi + 13]
        vpinsrd xmm0, xmm0, eax, 1
        lea     eax, [rdi + 14]
        vpinsrd xmm0, xmm0, eax, 2
        lea     eax, [rdi + 15]
        vpinsrd xmm0, xmm0, eax, 3
        lea     eax, [rdi + 8]
        vmovd   xmm1, eax
        lea     eax, [rdi + 9]
        vpinsrd xmm1, xmm1, eax, 1
        lea     eax, [rdi + 10]
        vpinsrd xmm1, xmm1, eax, 2
        lea     eax, [rdi + 11]
        vpinsrd xmm1, xmm1, eax, 3
        lea     eax, [rdi + 4]
        vmovd   xmm2, eax
        lea     eax, [rdi + 5]
        vpinsrd xmm2, xmm2, eax, 1
        lea     eax, [rdi + 6]
        vpinsrd xmm2, xmm2, eax, 2
        lea     eax, [rdi + 7]
        vpinsrd xmm2, xmm2, eax, 3
        lea     eax, [rdi + 1]
        vmovd   xmm3, edi
        vpinsrd xmm3, xmm3, eax, 1
        lea     eax, [rdi + 2]
        vpinsrd xmm3, xmm3, eax, 2
        lea     eax, [rdi + 3]
        vpinsrd xmm3, xmm3, eax, 3
        vinserti128     ymm0, ymm1, xmm0, 1
        vinserti128     ymm1, ymm3, xmm2, 1
        vmovdqa ymm2, ymmword ptr [rip + .LCPI0_0] # ymm2 =
[1,2,5,6,9,10,13,14,9,10,13,14,13,14,15,128,17,18,21,22,25,26,29,30,25,26,29,30,29,30,31,128]
        vpshufb ymm1, ymm1, ymm2
        vpermq  ymm1, ymm1, 232                 # ymm1 = ymm1[0,2,2,3]
        vmovdqa xmm3, xmmword ptr [rip + .LCPI0_1] # xmm3 =
[255,255,255,255,255,255,255,255]
        vpand   xmm1, xmm1, xmm3
        vpshufb ymm0, ymm0, ymm2
        vpermq  ymm0, ymm0, 232                 # ymm0 = ymm0[0,2,2,3]
        vpand   xmm0, xmm0, xmm3
        vpackuswb       xmm0, xmm1, xmm0
        vmovdqa xmmword ptr [rip + data], xmm0
        vzeroupper
        ret


GCC -O3 -march=haswell:
test(unsigned int):
        vmovd   xmm0, edi
        vmovdqa xmm2, XMMWORD PTR .LC2[rip]
        vpbroadcastw    xmm0, xmm0
        vpaddw  xmm1, xmm0, XMMWORD PTR .LC0[rip]
        vpaddw  xmm0, xmm0, XMMWORD PTR .LC1[rip]
        vpsrlw  xmm1, xmm1, 8
        vpsrlw  xmm0, xmm0, 8
        vpand   xmm1, xmm2, xmm1
        vpand   xmm2, xmm2, xmm0
        vpackuswb       xmm0, xmm1, xmm2
        vmovdqa XMMWORD PTR data[rip], xmm0
        ret


<a href="https://gcc.godbolt.org/z/zP4nWM">https://gcc.godbolt.org/z/zP4nWM</a></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>