<html>
    <head>
      <base href="http://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] extract_subvector shuffle disaster"
   href="http://llvm.org/bugs/show_bug.cgi?id=22359">22359</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86][AVX] extract_subvector shuffle disaster
          </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>This is a testcase I was considering using in a patch for <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [X86][AVX] separate stores are not being merged into a single 256bit store."
   href="show_bug.cgi?id=21711">bug 21711</a>, but
something is causing the AVX1/AVX2 codegen to go wrong. This doesn't happen
with SSE. 

We're trying to store half of a 256-bit vector here:

define void @f7(<8 x float> %v, <2 x float>* %ptr) {
  %idx2 = getelementptr inbounds <2 x float>* %ptr, i64 1

  %shuffle0 = shufflevector <8 x float> %v, <8 x float> undef, <2 x i32> <i32
0, i32 1>
  %shuffle1 = shufflevector <8 x float> %v, <8 x float> undef, <2 x i32> <i32
2, i32 3>

  store <2 x float> %shuffle0, <2 x float>* %ptr, align 8
  store <2 x float> %shuffle1, <2 x float>* %idx2, align 8
  ret void
}

$ ./llc extract.ll -mattr=sse -o -
...
    movups    %xmm0, (%rdi)
    retq

$ ./llc extract.ll -mattr=avx -o - 
...
    vpermilps    $231, %xmm0, %xmm1 ## xmm1 = xmm0[3,1,2,3]
    vpermilpd    $1, %xmm0, %xmm2 ## xmm2 = xmm0[1,0]
    vmovshdup    %xmm0, %xmm3    ## xmm3 = xmm0[1,1,3,3]
    vinsertps    $16, %xmm3, %xmm0, %xmm0 ## xmm0 = xmm0[0],xmm3[0],xmm0[2,3]
    vinsertps    $32, %xmm2, %xmm0, %xmm0 ## xmm0 = xmm0[0,1],xmm2[0],xmm0[3]
    vinsertps    $48, %xmm1, %xmm0, %xmm0 ## xmm0 = xmm0[0,1,2],xmm1[0]
    vmovups    %xmm0, (%rdi)
    vzeroupper
    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>