<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 - simple-loop-unswitch is too aggressive in unswitching leading to compile-time issues"
   href="https://bugs.llvm.org/show_bug.cgi?id=39544">39544</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>simple-loop-unswitch is too aggressive in unswitching leading to compile-time issues
          </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>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>fedor.v.sergeev@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21075" name="attach_21075" title="real testcase leading to excessive unswitch">attachment 21075</a> <a href="attachment.cgi?id=21075&action=edit" title="real testcase leading to excessive unswitch">[details]</a></span>
real testcase leading to excessive unswitch

On a relatively simple testcase simple-loop-unswitch goes unswitching too many
times, generating too many copies of loops and forcing compile-time to become
abnormally high.

] time ~/work/llvm-upstream/builds/linux-release/bin/opt
-enable-nontrivial-unswitch -licm -simple-loop-unswitch
after-reassociate-upstream.ll -disable-output  --stats                          

real    5m17.711s
user    4m33.670s
sys     0m0.188s
]

This testcase is a slightly simplified version of IR we generate on real java
code, so it is a very real practical issue for us.

Here is its loop structure (nothing really weird):
] ~/work/llvm-upstream/builds/linux-release/bin/opt -passes="print<loops>"
unswitch-compile-time.ll -disable-output 2>&1 | sed -n
's/\(Loop.at.depth.[0-9]*\).*/\1/p'
Loop at depth 1
Loop at depth 1
Loop at depth 1
Loop at depth 1
Loop at depth 1
Loop at depth 1
Loop at depth 1
    Loop at depth 2
    Loop at depth 2
        Loop at depth 3
            Loop at depth 4
                Loop at depth 5
                    Loop at depth 6
                        Loop at depth 7
                            Loop at depth 8
                                Loop at depth 9
                                    Loop at depth 10
                                        Loop at depth 11
                                            Loop at depth 12
                                                Loop at depth 13
                                                    Loop at depth 14
                                                    Loop at depth 14
                                                    Loop at depth 14
                                                    Loop at depth 14
]
It has ~2K lines and ~200 conditions:

] wc -l unswitch-compile-time.ll
2317 unswitch-compile-time.ll
] grep 'br i1 ' -c unswitch-compile-time.ll 
197
]

And it goes pretty fast with legacy unswitch:

] time ~/work/llvm-upstream/builds/linux-release/bin/opt
-enable-nontrivial-unswitch -licm -loop-unswitch unswitch-compile-time.ll
-disable-output

real    0m0.018s
user    0m0.018s
sys     0m0.000s
]</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>