<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 - [x86] try harder to reduce shuffle with zero operand"
   href="https://bugs.llvm.org/show_bug.cgi?id=40318">40318</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[x86] try harder to reduce shuffle with zero operand
          </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>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>spatel+llvm@rotateright.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>As noted here:
<a href="https://reviews.llvm.org/D56281">https://reviews.llvm.org/D56281</a>
...we should be able to do better than this:

define <8 x i16> @shift_zext(<8 x i16> %x) {
  %r = shufflevector <8 x i16> %x, <8 x i16> zeroinitializer, <8 x i32> <i32 1,
i32 9, i32 10, i32 11, i32 undef, i32 undef, i32 undef, i32 undef>
  ret <8 x i16> %r
}

$ llc -o - shufsse.ll 
        pxor    %xmm1, %xmm1
        punpcklwd       %xmm0, %xmm1    ## xmm1 =
xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
        pshufhw $232, %xmm1, %xmm0      ## xmm0 = xmm1[0,1,2,3,4,6,6,7]
        pshufd  $230, %xmm0, %xmm0      ## xmm0 = xmm0[2,1,2,3]
        pshuflw $75, %xmm0, %xmm0       ## xmm0 = xmm0[3,2,0,1,4,5,6,7]
        retq


Or an even worse example:

define <8 x i16> @shift_zext_worse
(<8 x i16> %x) {
  %r = shufflevector <8 x i16> %x, <8 x i16> zeroinitializer, <8 x i32> <i32 2,
i32 9, i32 10, i32 11, i32 undef, i32 undef, i32 undef, i32 undef>
  ret <8 x i16> %r
}

$ llc -o - shufsse.ll
        pxor    %xmm1, %xmm1
        punpcklwd       %xmm0, %xmm1    ## xmm1 =
xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
        pshufd  $39, %xmm1, %xmm0       ## xmm0 = xmm1[3,1,2,0]
        pshuflw $232, %xmm0, %xmm0      ## xmm0 = xmm0[0,2,2,3,4,5,6,7]
        pshufd  $232, %xmm0, %xmm0      ## xmm0 = xmm0[0,2,2,3]
        pshuflw $39, %xmm0, %xmm0       ## xmm0 = xmm0[3,1,2,0,4,5,6,7]
        retq

----------------------------------------------------------------------------

When shuffling with a zero operand, we should try harder to use logical shifts?
In all cases, 2 opposing shifts can put zero elements into all lanes.</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>