[PATCH] Improve isPotentiallyReachable

Nick Lewycky nlewycky at google.com
Fri Aug 9 16:52:15 PDT 2013


On 9 August 2013 00:51, Andrew Trick <atrick at apple.com> wrote:

>
>   This looks ok in the case of no LoopInfo.
>

Thanks.


>   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:
>
>       if (LI && LI->getLoopFor(BB))
>         return true;
>     // else fall through to the linear scan followed by path exploration
>     // just like the non-loopinfo case.
>

Good catch!

  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.
>
> http://llvm-reviews.chandlerc.com/D1247
>

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.

Okay, I'm going to audit all my uses of LoopInfo. Thank you.

Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130809/3d0678f8/attachment.html>


More information about the llvm-commits mailing list