<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 --- - [PPC] recognize the shufflevector equivalent of a vector select"
   href="https://llvm.org/bugs/show_bug.cgi?id=28531">28531</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[PPC] recognize the shufflevector equivalent of a vector select
          </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: PowerPC
          </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>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ cat shufsel.ll 
define <4 x i32> @foo(<4 x i32> %a, <4 x i32> %b) {
  %sel = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i32> %a,
<4 x i32> %b
  ret <4 x i32> %sel
}

define <4 x i32> @goo(<4 x i32> %a, <4 x i32> %b) {
  %shuf = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5,
i32 6, i32 3>
  ret <4 x i32> %shuf
}

These are functionally equivalent. Note that in <a href="http://reviews.llvm.org/D22114">http://reviews.llvm.org/D22114</a>
, there's a proposal to canonicalize to the shufflevector form of the IR.

We generate 'xxsel' and 'vperm' for a target with VSX. Is one better than the
other?

For an altivec target, the lowering to vsel is missed:

$ ./llc shufsel.ll -o - -mtriple=powerpc64 -mattr=altivec
foo:                                    # @foo    
    addis 3, 2, .LCPI0_0@toc@ha
    addis 4, 2, .LCPI0_1@toc@ha
    addi 3, 3, .LCPI0_0@toc@l
    addi 4, 4, .LCPI0_1@toc@l
    lvx 4, 0, 3
    lvx 5, 0, 4
    vand 3, 3, 4
    vand 2, 2, 5
    vor 2, 2, 3
    blr</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>