<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 --- - LoopDistribute domtree handling gives eternal loop"
   href="https://llvm.org/bugs/show_bug.cgi?id=30958">30958</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LoopDistribute domtree handling gives eternal loop
          </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>Windows NT
          </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=17572" name="attach_17572" title="Small program provoking the bug">attachment 17572</a> <a href="attachment.cgi?id=17572&action=edit" title="Small program provoking the bug">[details]</a></span>
Small program provoking the bug

Opt gets stuck in an eternal loop with the attached small program, using these
flags:

opt -simplifycfg -loop-distribute -instcombine loopdist_simplified.ll

The reason is that the LoopDistribute pass mess up the dominator tree and
introduce a cycle, so when the instcombiner needs to walk the dominator tree it
gets stuck in a tight eternal loop:

Program received signal SIGINT, Interrupt.
llvm::DominatorTreeBase<llvm::BasicBlock>::dominatedBySlowTreeWalk
(this=0x343d570, A=0x345e5e0, B=0x3455b70)
    at ../include/llvm/Support/GenericDomTree.h:220
220          B = IDom; // Walk up the tree

If we use this command line:
opt -loop-distribute -verify-dom-info loopdist_simplified.ll

... the verifier complains:

DominatorTree for function: f is not up to date!
Computed:
=============================--------------------------------
Inorder Dominator Tree: DFSNumbers invalid: 0 slow queries.
  [1] %0 {0,5}

Actual:
=============================--------------------------------
Inorder Dominator Tree: 
  [1] %0 {0,17}
    [2] %bb1 {1,16}
      [3] %bb2.lver.check {2,15}
        [4] %bb2.ph.lver.orig {3,6}
          [5] %bb2.lver.orig {4,5}
        [4] %bb2.ph.ldist1 {7,14}
          [5] %bb2.ldist1 {8,13}
            [6] %bb2.ph {9,12}
              [7] %bb2 {10,11}</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>