<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 - Loop unroll by N iterations takes O(N^2) time in domtree updater"
   href="https://bugs.llvm.org/show_bug.cgi?id=43134">43134</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Loop unroll by N iterations takes O(N^2) time in domtree updater
          </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>Windows NT
          </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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>efriedma@quicinc.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>alina.sbirlea@gmail.com, brzycki@gmail.com, kubakuderski@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Testcase:

unsigned x() {
  unsigned z = 3;
  unsigned LIMIT = 16000;
  _Pragma("unroll(16384)") for (int i = 0; i < LIMIT; ++i)
    z *= z;
  return z;
}

The compile times look roughly like the following, with "clang -O2 -mllvm
-unroll-threshold=999999":

LIMIT=1000: 0.3s
LIMIT=2000: 1.0s
LIMIT=4000: 3.6s
LIMIT=8000: 14.3s
LIMIT=16000: 57.8s

This is obviously non-linear; I think it's roughly quadratic.  -ftime-report
says the time is spent in unrolling.  I "profiled" in a debugger, and it looks
like the time is spent updating the domtree.

Without the "-unroll-threshold", LLVM refuses to unroll the loop 16000 times,
but it will unroll 8000 times.</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>