<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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][AVX] suboptimal splats of high elements of 256-bit vectors"
   href="https://llvm.org/bugs/show_bug.cgi?id=23027">23027</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86][AVX] suboptimal splats of high elements of 256-bit vectors
          </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>normal
          </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>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>AVX shuffling of 256-bit vectors isn't supported very well in hardware. It
looks like real instructions for this don't show up until AVX2.

But I think we can do better than this by using vpermild + vperm2f128:

define <4 x double> @shuffle_splat_v4f64_3(<4 x double> %v) {
  %z = shufflevector <4 x double> %v, <4 x double> undef, <4 x i32> <i32 3, i32
3, i32 3, i32 3>
  ret <4 x double> %z
}

$ ./llc -o - -mattr=avx splat256.ll 
...
    vextractf128    $1, %ymm0, %xmm0
    vmovhlps    %xmm0, %xmm0, %xmm0 ## xmm0 = xmm0[1,1]
    vinsertf128    $1, %xmm0, %ymm0, %ymm0
    retq</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>