<div dir="ltr">On 9 August 2013 00:51, Andrew Trick <span dir="ltr"><<a href="mailto:atrick@apple.com" target="_blank">atrick@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
  This looks ok in the case of no LoopInfo.<br></blockquote><div><br></div><div>Thanks.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

  The LoopInfo case looks wrong to begin with, and your patch could result in more linear scans. For instructions in the same block, why don't we do the loop check first:<br>
<br>
      if (LI && LI->getLoopFor(BB))<br>
        return true;<br>
    // else fall through to the linear scan followed by path exploration<br>
    // just like the non-loopinfo case.<br></blockquote><div><br></div><div>Good catch!</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

  The current code skips the path exploration if we're not in a loop! I don't understand how this is correct in the presence of irreducible control flow.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D1247" target="_blank">http://llvm-reviews.chandlerc.com/D1247</a><br>
</blockquote></div><br></div><div class="gmail_extra">I missed the requirement that natural loops have a single header which dominates all other blocks. Got the rest of the algorithm, I just missed that clause in the definition of natural loops. I then went on to conclude that LoopInfo will always find *some* loop whenever there exists a backedge (that is, any CFG edge which is not also a dominator edge), which would be true if not for the requirement of a header block.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Okay, I'm going to audit all my uses of LoopInfo. Thank you.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Nick</div><div class="gmail_extra">

<br></div></div>