<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 --- - Exponential expansion in IndVarSimplify/ScalarEvolutionExpander"
   href="https://llvm.org/bugs/show_bug.cgi?id=31543">31543</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Exponential expansion in IndVarSimplify/ScalarEvolutionExpander
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </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>opt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jesper.antonsson@ericsson.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>Created <span class=""><a href="attachment.cgi?id=17805" name="attach_17805" title="reduced ll file that gives exponential expansion with opt">attachment 17805</a> <a href="attachment.cgi?id=17805&action=edit" title="reduced ll file that gives exponential expansion with opt">[details]</a></span>
reduced ll file that gives exponential expansion with opt

File size of output file and time taken by opt is an exponential function of a
loop iteration count for the attached file:

 opt -S -O1 -o foo.opt.ll foo.ll

alternatively, if -O1 is expanded and reduced:

 opt -S -instcombine -loop-rotate -licm -instcombine -indvars -o foo.opt.ll
foo.ll

It's IndVarSimplify::rewriteLoopExitValues() that calls ScalarEvolutionExpander
to calculate loop exit value, but the expansion becomes exponential.

If I change the loop iteration count on this line:

 %_tmp12 = icmp slt i16 %_tmp11, 6

The output ll file grows and compilation time lengthens exponentially. Some
sample values:

bound  file size of foo.opt.ll
6      4912
7      8944
8      17088
..
15     2065266</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>