[PATCH] D12719: ScalarEvolution assume hanging bugfix

Nick Lewycky via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 8 20:50:21 PDT 2015


On 8 September 2015 at 20:27, Sanjoy Das <sanjoy at playingwithpointers.com>
wrote:

> sanjoy added a comment.
>
> I don't think this is an infinite loop (Piotr, can you please verify
> this?), it is probably an O(n!) recursion where n == number of the
> assumptions.
>
> ScalarEvolution::isImpliedCond already guards for infinite loops via
> MarkPendingLoopPredicate.  However, if you have
>
> assume_0()
>  assume_1()
>  assume_2()
>  assume_3()
>
> then the recursive call to isImpliedCond(assume_2, X) may end up
> calling isImpliedCond(assume_1, Y) and that may end up calling
> isImpliedCond(assume_0, Y) and that may end up calling
> isImpliedCond(assume_3, Y).  This way, even though we're protected
> against full on infinite recursion, we'll still explore all 4! = 24
> possibilities.
>

I agree it's probably O(n!) instead of infinite, but that's slow enough.

I think the check with LoopContinuePredicate is fine since it only
> calls isImpliedCond if there is exactly one latch in the loop.  This
> means that the above n! possibility is really only a 1! = 1
> possibility for LoopContinuePredicate.
>
> But this from memory, so please double check.
>

Both tests are protected by there being exactly one latch in the loop (we
exit early if there's not one latch). I'm not sure what makes the
LoopContinuePredicate check safer?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150908/f83d14c1/attachment.html>


More information about the cfe-commits mailing list