<div dir="ltr">@Sanjoy, what's the issue with <nsw>? Moreover, why can't SCEV detect that x is loop invariant and just take the diff/incr?</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 16, 2016 at 2:50 PM, Kevin Choi <span dir="ltr"><<a href="mailto:code.kchoi@gmail.com" target="_blank">code.kchoi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Assuming compiler assumes program is free of UB, I suppose trip count of 2 is always valid. I misplaced valid to trip count when it should've been "program is valid only for x in [0.6]".</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 16, 2016 at 2:29 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
> On Sep 16, 2016, at 2:23 PM, Sanjoy Das <<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.co<wbr>m</a>> wrote:<br>
><br>
> Hi Mehdi,<br>
><br>
> Mehdi Amini wrote:<br>
> ><br>
> >> On Sep 16, 2016, at 1:56 PM, Kevin Choi via llvm-dev<br>
> >> <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a> <mailto:<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.or<wbr>g</a>>> wrote:<br>
> >><br>
> >> > int mat[9][9][9];<br>
> >> > for (p = (x+1) ; p < (x+3) ;p++)<br>
> >> > mat[x][p-1][i] = mat[x][p-1][i] + 5;____<br>
> >> > }<br>
> >> The trip count of 2 should be valid for x in [0,6].<br>
> ><br>
> > It is not clear to me why the trip count of 2 isn’t *always* valid.<br>
><br>
> It is always valid to return 2 as the trip count.  But SCEV today is<br>
> not always able to exploit nsw/nuw due to some systemic issues.<br>
<br>
</span>I understood that SCEV can’t deduce it.<br>
The point was more “abstracting the current implementation limitation”, there is no fundamental issue with this code.<br>
<br>
—<br>
<span><font color="#888888">Mehdi<br>
<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>