<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 - Performance regression(with D33136) due to a conservative assumption in BasicAA."
   href="https://bugs.llvm.org/show_bug.cgi?id=33549">33549</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Performance regression(with D33136) due to a conservative assumption in BasicAA.
          </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>Windows NT
          </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>farhana.aleen@gmail.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=18685" name="attach_18685" title="a small reproducer">attachment 18685</a> <a href="attachment.cgi?id=18685&action=edit" title="a small reproducer">[details]</a></span>
a small reproducer

D33136 causes performance regression on a eembc benchmark. The regression was
also reported by David Green with a small reproducer which I attached here.

This issue is:
D33136 prevents isAddOfNonZero() from looking at Phi nodes during basic alias
analysis. It does that because it cannot prove that the values(/indices) are
not from the same iteration(or even they are from the different iterations it
does not know the distance between the two loop iteration). So, conservatively
it always assumes that indices are from different iterations.

As a result "%2 = load %arrayidx4" does not get pre'd since it alias analysis
finds store i32 %sub, i32* %arrayidx, align 4, !tbaa !3 as a clobbering store.

Here is the code snippet from the test:

%arrayidx = getelementptr inbounds [32 x i32], [32 x i32]* @Data, i32 0, i32
%add
%arrayidx4 = getelementptr inbounds [32 x i32], [32 x i32]* @Data, i32 0, i32
%i.030
%0 = load i32, i32* %arrayidx, align 4, !tbaa !3
%1 = load i32, i32* %arrayidx4, align 4, !tbaa !3
%sub = sub nsw i32 %1, %0
store i32 %sub, i32* %arrayidx, align 4, !tbaa !3
%2 = load i32, i32* %arrayidx4, align 4, !tbaa !3</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>