<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: missed canonicalization ((-1 * (0 smin %n)) + %n) is actually just (0 smax %n)"
   href="https://bugs.llvm.org/show_bug.cgi?id=46939">46939</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SCEV: missed canonicalization  ((-1 * (0 smin %n)) + %n)  is actually just  (0 smax %n)
          </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>Global Analyses
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>lebedev.ri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm not really sure how SCEV canonicalization is performed, but
<a href="https://rise4fun.com/Alive/GsleR">https://rise4fun.com/Alive/GsleR</a>

; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s

; FIXME: ((-1 * (0 smin %n)) + %n)  is actually just  (0 smax %n)

declare void @iteration()

define void @reverse_loop(i32 %n) {
; CHECK-LABEL: 'reverse_loop'
; CHECK-NEXT:  Classifying expressions for: @reverse_loop
; CHECK-NEXT:    %i.011 = phi i32 [ %n, %for.body.lr.ph ], [ %dec, %for.body ]
; CHECK-NEXT:    --> {%n,+,-1}<nsw><%for.body> U: full-set S: full-set Exits:
(0 smin %n) LoopDispositions: { %for.body: Computable }
; CHECK-NEXT:    %dec = add nsw i32 %i.011, -1
; CHECK-NEXT:    --> {(-1 + %n),+,-1}<nw><%for.body> U: full-set S: full-set
Exits: (-1 + (0 smin %n)) LoopDispositions: { %for.body: Computable }
; CHECK-NEXT:  Determining loop execution counts for: @reverse_loop
; CHECK-NEXT:  Loop %for.body: backedge-taken count is ((-1 * (0 smin %n)) +
%n)
; CHECK-NEXT:  Loop %for.body: max backedge-taken count is 2147483647
; CHECK-NEXT:  Loop %for.body: Predicated backedge-taken count is ((-1 * (0
smin %n)) + %n)
; CHECK-NEXT:   Predicates:
; CHECK:       Loop %for.body: Trip multiple is 1
;
entry:
  %cmp10 = icmp sgt i32 %n, -1
  br i1 %cmp10, label %for.body.lr.ph, label %for.cond.cleanup

for.body.lr.ph:
  br label %for.body

for.body:
  %i.011 = phi i32 [ %n, %for.body.lr.ph ], [ %dec, %for.body ]
  call void @iteration()
  %dec = add nsw i32 %i.011, -1
  %cmp = icmp sgt i32 %i.011, 0
  br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit

for.cond.cleanup.loopexit:
  br label %for.cond.cleanup

for.cond.cleanup:
  ret void
}</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>