<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 - [SCEV] Inconsistent SCEV formation for zext"
   href="https://bugs.llvm.org/show_bug.cgi?id=36738">36738</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SCEV] Inconsistent SCEV formation for zext
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>Global Analyses
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>pankaj.chawla@intel.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=20063" name="attach_20063" title="test case">attachment 20063</a> <a href="attachment.cgi?id=20063&action=edit" title="test case">[details]</a></span>
test case

SCEV is behaving inconsistently when forming SCEV for this zext instruction in
the attached test case-
%conv5 = zext i32 %dec to i64

If we request a SCEV for the instruction, it returns-
(zext i32 {{-1,+,1}<nw><%for.body>,+,-1}<nw><%for.body7> to i64)

This can be seen by invoking-
$ opt -analyze -scalar-evolution inconsistent-scev-zext.ll

But when computing the backedge taken count of the containing loop for.body7,
it is able to push zext inside the AddRec and forms the following for the same
instruction-
{(zext i32 {-1,+,1}<%for.body> to i64),+,-1}<nw><%for.body7>

This allows ScalarEvolution to compute a valid backedge taken count for the
loop.

Reference to email discussion regarding the bug-
<a href="http://lists.llvm.org/pipermail/llvm-dev/2018-February/121107.html">http://lists.llvm.org/pipermail/llvm-dev/2018-February/121107.html</a></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>