<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 - [PCG] Poor shuffle lane tracking"
   href="https://bugs.llvm.org/show_bug.cgi?id=35454">35454</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[PCG] Poor shuffle lane tracking
          </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>konstantin.belochapka@sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>the compiler produces suboptimal code in the following cases:

///
__m128i laneTest1_0( __m128i v )
{
    v = _mm_shuffle_epi32( v, _MM_SHUFFLE(0,1,2,3) ); // mirror lanes
    v = _mm_add_epi8( v, v );
    v = _mm_shuffle_epi32( v, _MM_SHUFFLE(0,1,2,3) ); // mirror lanes
    return v;
}

    vpshufd    $27, %xmm0, %xmm0       # xmm0 = xmm0[3,2,1,0]
    vpaddb    %xmm0, %xmm0, %xmm0
    vpshufd    $27, %xmm0, %xmm0       # xmm0 = xmm0[3,2,1,0]
    retq


__m128i laneTest1_1( __m128i v )
{
    v = _mm_shuffle_epi32( v, _MM_SHUFFLE(0,1,2,3) ); // mirror lanes
    v = _mm_add_epi16( v, v );
    v = _mm_shuffle_epi32( v, _MM_SHUFFLE(0,1,2,3) ); // mirror lanes
    return v;
}

    vpshufd    $27, %xmm0, %xmm0       # xmm0 = xmm0[3,2,1,0]
    vpaddw    %xmm0, %xmm0, %xmm0
    vpshufd    $27, %xmm0, %xmm0       # xmm0 = xmm0[3,2,1,0]
    retq

In both cases, the shuffles could be optimized out.
Note that this happens only when the shuffle type doesn't match the
arithmetic/binop operation.
For example, the above test cases, shuffles work on packed 32-bit integer
values, while the vector add instructions work on packed 8/16 bits values.</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>