<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 - shufflevector produces sub-optimal code on AVX2"
   href="https://bugs.llvm.org/show_bug.cgi?id=36933">36933</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>shufflevector produces sub-optimal code on AVX2
          </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>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>new bugs
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following operation does a shift %left one byte to the right, while
shifting the rightmost byte of %right into the leftmost byte of %left:

define void @foo(<32 x i8>*, <32 x i8>* %left, <32 x i8>*  %right) unnamed_addr
#0 {
  %2 = load <32 x i8>, <32 x i8>* %left, align 32
  %3 = load <32 x i8>, <32 x i8>* %right, align 32
  %4 = shufflevector <32 x i8> %2, <32 x i8> %3, 
          <32 x i32> 
          <i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, 
           i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, 
           i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, 
           i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62>
  store <32 x i8> %4, <32 x i8>* %0, align 32
  ret void
}

but LLVM produces the following sub-optimal assembly:

.LCPI0_0:
  .byte 255 # 0xff
  ...
  .byte 255 # 0xff
  .byte 0 # 0x0
foo: # @foo
  vmovdqa ymm0, ymmword ptr [rsi]
  vmovdqa ymm1, ymmword ptr [rip + .LCPI0_0]
  vpblendvb ymm0, ymm0, ymmword ptr [rdx], ymm1
  vpermq ymm1, ymm0, 78
  vpalignr ymm0, ymm0, ymm1, 15
  vmovdqa ymmword ptr [rdi], ymm0
  vzeroupper
  ret

where instead of doing a vmovdqa (to load a constant), vpblendvb, vperm2i128
and vpalignr it should just do a vperm2i128 followed by vpalignr.</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>