<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 --- - Incorrect VMX/Altivec Code Generation - Mis-using splat instructions" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24216&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=-6-84vKebcCEOQxA7A4NE1OAxy7Z1R1cEV-yBw1BRjM&s=gkQ372JdsPBEfXptHcFPnPtW2XmXXmAhtmwr5eYK6Fk&e=">24216</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect VMX/Altivec Code Generation - Mis-using splat instructions
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>llc
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tjkenney@us.ibm.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>Created <span class=""><a href="attachment.cgi?id=14629" name="attach_14629" title="tarball w/ .cl source, .ll source, .s output &amp; Makefile">attachment 14629</a> <a href="attachment.cgi?id=14629&action=edit" title="tarball w/ .cl source, .ll source, .s output &amp; Makefile">[details]</a></span>
tarball w/ .cl source, .ll source, .s output & Makefile

This bug causes the compiler to emit splat instructions which 'splat' the wrong
bytes from the source register. The issue is that the function
PPC::isSplatShuffleMask() in PPCISelLowering.cpp does not ensure that the
'splat' pattern found is requesting bytes that are aligned on an 'EltSize'
boundary. Therefore, the compiler emits splat instructions when it shouldn't;
the operation should be performed by a vperm or some other sequence of
instructions instead. Attached is an OpenCL-C function & the generated IR that
trigger this bug.

A simple fix would be to add this check in isSplatShuffleMask() with the
following line:

  if (N->getMaskElt(0) % EltSize) return false;

This causes the VECTOR_SHUFFLE node to be lowered to a vperm inst instead. Is
there a better solution? Would a shift followed by a splat be preferred over a
vperm?</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>