<div dir="ltr">For and exit block to be immediately dominated by something outside the loop, it implies not all paths from that dominator, to the exit block, go through the loop.<div>Loop simplify claims to transform all loops for that to not be true (IE that all loop exits are dominated by the header)</div><div>If we allow lcssa for non-loopsimplify'd loops, then the following would suffice:</div><div><br></div><div><br></div><div>     | --- A</div><div>     |      |</div><div>     |      B<-</div><div>     |      |    |</div><div>     |--->C --</div><div>            |</div><div>           D</div><div><br></div><div>C is the loop exit block, and it is immediately dominated by A.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 12, 2017 at 6:03 PM, Davide Italiano via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">davide added inline comments.<br>
<br>
<br>
================<br>
Comment at: lib/Transforms/Utils/LCSSA.<wbr>cpp:90<br>
<span class="">     Loop *L = LI.getLoopFor(InstBB);<br>
+    assert(L && "tinky winky");<br>
     if (!LoopExitBlocks.count(L))<br>
</span>----------------<br>
Please ignore this assert, it helped me to find bugs during the development, I think it can committed separately (with a proper message)<br>
<br>
<br>
================<br>
Comment at: lib/Transforms/Utils/LCSSA.<wbr>cpp:274-277<br>
<span class="">+    // Exit blocks can have an immediate dominator which doesn't belong to<br>
+    // the loop, I think. XXX: this may be overcautious, check again.<br>
+    if (!L.contains(IDomBB))<br>
+      continue;<br>
</span>----------------<br>
I'm not entirely sure if this one is needed. I'll try to find examples where this can happen && remove and see if that triggers failures in the testsuite.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D31843" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D31843</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>