<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 8 September 2015 at 20:27, Sanjoy Das <span dir="ltr"><<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">sanjoy added a comment.<br>
<br>
I don't think this is an infinite loop (Piotr, can you please verify<br>
this?), it is probably an O(n!) recursion where n == number of the<br>
assumptions.<br>
<br>
ScalarEvolution::isImpliedCond already guards for infinite loops via<br>
MarkPendingLoopPredicate.  However, if you have<br>
<br>
assume_0()<br>
 assume_1()<br>
 assume_2()<br>
 assume_3()<br>
<br>
then the recursive call to isImpliedCond(assume_2, X) may end up<br>
calling isImpliedCond(assume_1, Y) and that may end up calling<br>
isImpliedCond(assume_0, Y) and that may end up calling<br>
isImpliedCond(assume_3, Y).  This way, even though we're protected<br>
against full on infinite recursion, we'll still explore all 4! = 24<br>
possibilities.<br></blockquote><div><br></div><div>I agree it's probably O(n!) instead of infinite, but that's slow enough.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think the check with LoopContinuePredicate is fine since it only<br>
calls isImpliedCond if there is exactly one latch in the loop.  This<br>
means that the above n! possibility is really only a 1! = 1<br>
possibility for LoopContinuePredicate.<br>
<br>
But this from memory, so please double check.<br></blockquote><div><br></div><div>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?</div></div></div></div>