<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][SSE] extra pshufhw generated in simple shuffle code"
   href="https://bugs.llvm.org/show_bug.cgi?id=34686">34686</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86][SSE] extra pshufhw generated in simple shuffle code
          </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>cox2@cooper.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Trunk turns these two shuffles into three (The commented out line is equivalent
and generates the same 3 shuffles):

#include <emmintrin.h>
__m128i m(__m128i i) {
    const __m128i a = _mm_shufflelo_epi16(i, 0x14);
    return _mm_shuffle_epi32(a, 0x44);
    // return _mm_unpacklo_epi64(a, a);
}

clang -S -O3 test.c -o -
m:
        pshufd  $196, %xmm0, %xmm0      # xmm0 = xmm0[0,1,0,3]
        pshuflw $20, %xmm0, %xmm0       # xmm0 = xmm0[0,1,1,0,4,5,6,7]
        pshufhw $20, %xmm0, %xmm0       # xmm0 = xmm0[0,1,2,3,4,5,5,4]
        retq

This can be observed at all optimization levels above 0.

I'd expect the same output that gcc generates:
gcc -S -O3 test.c -o -
m:
        pshuflw $20, %xmm0, %xmm0
        pshufd  $68, %xmm0, %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>