<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 - LoopVectorizer is analyzing poorly due to unoptimized input"
   href="https://bugs.llvm.org/show_bug.cgi?id=32698">32698</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LoopVectorizer is analyzing poorly due to unoptimized input
          </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>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </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=18305" name="attach_18305" title="automatically reduced test case with loop.">attachment 18305</a> <a href="attachment.cgi?id=18305&action=edit" title="automatically reduced test case with loop.">[details]</a></span>
automatically reduced test case with loop.

I came across a loop that for the loop vectorizer looks like:

for.body33:
  %indvars.iv1225 = phi i64 
  %typed_outval.1909 = phi i32
  %arrayidx36 = getelementptr 
  %58 = load i8, i8* %arrayidx36, align 1, !tbaa !11
  %conv37 = zext i8 %58 to i32
  %conv38 = and i32 %typed_outval.1909, 255
  %add39 = add nuw nsw i32 %conv38, %conv37
  %indvars.iv.next1226 = add nsw i64 %indvars.iv1225, 1
  %cmp31 = icmp slt i64 %indvars.iv.next1226, %57
  br i1 %cmp31, label %for.body33, label %for.end43.loopexit


It then thinks about these instructions with TTI individually. The problem is
that this is a phi that later gets optimized by InstCombine, because it is
actually just an i8 value, due to the 'and 255'.

A first thought is to run the instcombiner or some similar phi optimizer before
LoopVectorizer. Another idea is that it seems that SROA is introducing this
phi, which it could optimize?

Why is this not done? Compile time?

bin/opt -mtriple=s390x-unknown-linux -mcpu=z13 -O3 ./LoopVec_phi.ll -o
./out.opt.ll -S -debug-only=loop-vectorize</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>