<html>
    <head>
      <base href="http://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 --- - [SCEV] Negative backedge-taken count on signed integer wrap of the induction variable"
   href="http://llvm.org/bugs/show_bug.cgi?id=17173">17173</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SCEV] Negative backedge-taken count on signed integer wrap of the induction variable
          </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>Global Analyses
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>surfmaths@free.fr
          </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=11173" name="attach_11173" title="Simple loop with bit-width minimization of the induction variable">attachment 11173</a> <a href="attachment.cgi?id=11173&action=edit" title="Simple loop with bit-width minimization of the induction variable">[details]</a></span>
Simple loop with bit-width minimization of the induction variable

In case the induction variable undergoes a legal signed wrap, the exit
condition is usually negative. (cf: example code where the induction variable
bit-width has been minimized)

The Scalar Evolution Analysis gives a negative backedge-taken count in such
cases.

To reproduce:

$ opt -scalar-evolution -analyze test.ll
Printing analysis 'Scalar Evolution Analysis' for function 'test':
Classifying expressions for: @test
  %i = phi i7 [ 0, %preheader ], [ %i.1, %body.incr ]
  -->  {0,+,1}<%header>        Exits: -28
  %tmp = zext i7 %i to i64
  -->  {0,+,1}<nuw><nsw><%header>        Exits: 100
  %A.addr = getelementptr [100 x i32]* @A, i64 0, i64 %tmp
  -->  {@A,+,4}<%header>        Exits: (400 + @A)
  %A.load = load i32* %A.addr, align 4
  -->  %A.load        Exits: <<Unknown>>
  %A.inc = zext i7 %i to i32
  -->  {0,+,1}<nuw><nsw><%header>        Exits: 100
  %A.val = add nsw i32 %A.load, %A.inc
  -->  ({0,+,1}<nuw><nsw><%header> + %A.load)        Exits: <<Unknown>>
  %i.1 = add i7 %i, 1
  -->  {1,+,1}<nw><%header>        Exits: -27
Determining loop execution counts for: @test
Loop %header: backedge-taken count is -28
Loop %header: max backedge-taken count is -28


git-svn-id: <a href="https://llvm.org/svn/llvm-project/llvm/trunk@190205">https://llvm.org/svn/llvm-project/llvm/trunk@190205</a>
91177308-0d34-0410-b5e6-96231b3b80d8</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>