<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 - [VectorCombine] transform shuffle of binops with common operand"
   href="https://bugs.llvm.org/show_bug.cgi?id=52178">52178</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[VectorCombine] transform shuffle of binops with common operand
          </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>Scalar Optimizations
          </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></table>
      <p>
        <div>
        <pre>Adapted/reduced from the regression test in <a href="https://reviews.llvm.org/D111800">https://reviews.llvm.org/D111800</a>
(that example could have further shuffle combining which would eliminate a
shuffle and almost definitely be a win):

define <3 x i3> @src(<3 x i3> %x, <3 x i3> %y, <3 x i3> %z) {
  %a1 = sub <3 x i3> %x, %y
  %a2 = sub <3 x i3> %x, %z
  %r = shufflevector <3 x i3> %a1, <3 x i3> %a2, <3 x i32> <i32 0, i32 5, i32
3>
  ret <3 x i3> %r
}

define <3 x i3> @tgt(<3 x i3> %x, <3 x i3> %y, <3 x i3> %z) {
  %s1 = shufflevector <3 x i3> %x, <3 x i3> %x, <3 x i32> <i32 0, i32 5, i32 3>
  %s2 = shufflevector <3 x i3> %y, <3 x i3> %z, <3 x i32> <i32 0, i32 5, i32 3>
  %r2 = sub <3 x i3> %s1, %s2
  ret <3 x i3> %r2
}

<a href="https://alive2.llvm.org/ce/z/d8zB4D">https://alive2.llvm.org/ce/z/d8zB4D</a>

Note: the shuffle of '%x' can be reduced to a unary shuffle; I left the mask
as-is to show that we're re-using the incoming shuffle mask.

As long as the shuffle is no more expensive than the binop, this should be a
win and would potentially allow subsequent combines.</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>