<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 - SLP regression on SystemZ"
   href="https://bugs.llvm.org/show_bug.cgi?id=32406">32406</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SLP regression on SystemZ
          </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>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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>paulsson@linux.vnet.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18165" name="attach_18165" title="function that loop lives in -- not able to reduce furhter.">attachment 18165</a> <a href="attachment.cgi?id=18165&action=edit" title="function that loop lives in -- not able to reduce furhter.">[details]</a></span>
function that loop lives in -- not able to reduce furhter.

I have come across a major regression resulting after SLP vectorization (+18%
on SystemZ, just for enabling SLP). This all relates to one particular very hot
loop.

Scalar code:
  %conv252 = zext i16 %110 to i64
  %conv254 = zext i16 %111 to i64
  %sub255 = sub nsw i64 %conv252, %conv254
  ... repeated

SLP output:
  %101 = zext <16 x i16> %100 to <16 x i64>
  %104 = zext <16 x i16> %103 to <16 x i64>
  %105 = sub nsw <16 x i64> %101, %104
  %106 = trunc <16 x i64> %105 to <16 x i32>
  for each element e 0:15
   %107 = extractelement <16 x i32> %106, i32 e
   %108 = sext i32 %107 to i64

The vectorized code should in this case only have to be

  %101 = zext <16 x i16> %100 to <16 x i64>
  %104 = zext <16 x i16> %103 to <16 x i64>
  %105 = sub nsw <16 x i64> %101, %104
  for each element e 0:15
   %107 = extractelement <16 x i64> %105, i32 e

,but this does not get handled so for all the 16 elements, extracts *and
extends* are done.

I see that there is a special function in SLP vectorizer that does this
truncation and extract+extend whenever possible. Is this the place to fix this?

Or would it be better to rely on InstCombiner?

Is this truncation done by SLP with the assumption that it is free to extend an
extracted element? On SystemZ, this is not true.

/Jonas


Run
bin/opt -O3 -S -o out.opt.ll -mtriple=s390x-linux-gnu -mcpu=z13
SetupFastFullPelSearch.ll

Bad code lives in for.body249 after SLP</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>