<html>
    <head>
      <base href="https://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 --- - IRCE breaks loop-info"
   href="https://llvm.org/bugs/show_bug.cgi?id=28944">28944</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>IRCE breaks loop-info
          </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>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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>michael.v.zolotukhin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When trying to improve LoopInfo verifier, I found that one of IRCE tests
started to fail. Looks like it doesn't update LI as it creates new loops, or
something like this.

To reproduce apply a patch from <a href="https://reviews.llvm.org/D23437">https://reviews.llvm.org/D23437</a> and then:

$ cat fail.ll
define void @inner_loop(i32* %arr, i32* %a_len_ptr, i32 %n) {
entry:
  %len = load i32, i32* %a_len_ptr, !range !0
  %first.itr.check = icmp sgt i32 %n, 0
  br i1 %first.itr.check, label %loop, label %exit

loop:                                             ; preds = %in.bounds, %entry
  %idx = phi i32 [ 0, %entry ], [ %idx.next, %in.bounds ]
  %idx.next = add i32 %idx, 1
  %abc = icmp slt i32 %idx, %len
  br i1 %abc, label %in.bounds, label %out.of.bounds

in.bounds:                                        ; preds = %loop
  %addr = getelementptr i32, i32* %arr, i32 %idx
  store i32 0, i32* %addr
  %next = icmp slt i32 %idx.next, %n
  br i1 %next, label %loop, label %exit

out.of.bounds:                                    ; preds = %loop
  ret void

exit:                                             ; preds = %in.bounds, %entry
  ret void
}

!0 = !{i32 0, i32 2147483647}

$ opt -verify-loop-info -irce-print-changed-loops -irce < ww.ll -S
irce: in function inner_loop: constrained Loop at depth 1 containing:
%loop<header><exiting>,%in.bounds<latch><exiting>
Assertion failed: (LoopHeaders1.size() == LoopHeaders2.size() && "LoopInfo is
incorrect."), function verifyByRecomputation, file
/Users/mvzolotu/devel/trunk/llvm/include/llvm/Analysis/LoopInfoImpl.h, line
600.
Stack dump:
0.      Program arguments: bin/opt -verify-loop-info -irce-print-changed-loops
-irce -S
1.      Running pass 'Function Pass Manager' on module '<stdin>'.
2.      Running pass 'Loop Pass Manager' on function '@inner_loop'
Abort trap: 6</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>