<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 --- - High loop unroll counts can result in long compile times"
   href="http://llvm.org/bugs/show_bug.cgi?id=20058">20058</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>High loop unroll counts can result in long compile times
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>meheff@google.com
          </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>Compilation can take a long time with high loop counts and is looks to be
quadratic with loop count.  The addition of loop unroll pragmas
(<a href="http://reviews.llvm.org/D4147">http://reviews.llvm.org/D4147</a>, not yet submitted) will make it more likely
that users will encounter this bad behavior.

Attached is the IR from the following simple C code:

void loop(int *a)
{
  for (int i = 0; i < 1000000; i++) {
    a[i]++;
  }
}

I measured ~2s to unroll this loop 16K times with release build at head, ~10s
to unroll roll it 32K times, and ~50s for 64K, so it appears to be growing (at
least) quadratically.  Profiling suggests time is being taken in somewhere
beneath llvm::UnrollLoop -> FoldBlockIntoPredecessor ->
llvm::ScalarEvolution::forgetLoop.

Run:
opt loop.ll -loop-rotate -loop-unroll -unroll-count 16000 -unroll-allow-partial
-unroll-threshold=10000000</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>