<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 --- - Canonicalization/simplification loop between LoopSimplify and CFGSimplify can cause compilation time slowdown"
   href="https://llvm.org/bugs/show_bug.cgi?id=30895">30895</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Canonicalization/simplification loop between LoopSimplify and CFGSimplify can cause compilation time slowdown
          </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>igor@azulsystems.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>LoopSimplify requires loop preheader to dominate all exit blocks. In order to
achieve that it splits loop exit blocks that have predecessors outside of the
loop. CFGSimplify merges them back. This cycle repeats multiple times during
compilation.

This process causes around 40% compile time slowdown on one of our internal
out-of-tree tests. This test is somewhat absurd since it contains around 1700
loops nested in each other up to the 8th level.

You can observe described behaviour using this simple reproducer:

declare void @some_call()

define i32 @test(i32 %cnt, i32 %cnt-inner) personality i32* ()*
@"personality_function" {
entry:
  br label %loop

loop:
  %i = phi i32 [0, %entry], [%i.next, %loop-latch]
  invoke void @some_call()
    to label %inner-loop unwind label %exception1

inner-loop:
  %j = phi i32 [0, %loop], [%j.next, %inner-loop-latch]
  invoke void @some_call()
    to label %inner-loop-latch unwind label %exception1

inner-loop-latch:
  %j.next = add i32 %j, 1
  %inner-exit-cond = icmp sle i32 %j.next, %cnt-inner
  br i1 %inner-exit-cond, label %inner-loop, label %loop-latch

loop-latch:
  %i.next = add i32 %i, 1
  %exit-cond = icmp sle i32 %i.next, %cnt
  br i1 %exit-cond, label %loop, label %loop-normal-exit

loop-normal-exit:
  ret i32 0

exception1:
  %landing-pad1 = landingpad { i8*, i32 }
          cleanup
  ret i32 1

exception2:
  %landing-pad2 = landingpad { i8*, i32 }
          cleanup
  ret i32 2
}

declare i32* @"personality_function"()</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>