<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 16, 2016, at 1:56 PM, Kevin Choi via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">> <span style="color:rgb(79,129,189);font-family:calibri,sans-serif;font-size:14.6667px" class="">int mat[9][9][9];<br class=""></span>> <span style="color:rgb(79,129,189);font-family:calibri,sans-serif;font-size:11pt" class="">for (p = (x+1) ; p < (x+3) ;p++)</span></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'times new roman', serif;" class=""><span style="font-size:11pt;font-family:calibri,sans-serif;color:rgb(79,129,189)" class="">>    mat[x][p-1][i] = mat[x][p-1][i] + 5;<u class=""></u><u class=""></u></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'times new roman', serif;" class=""><span style="font-size:11pt;font-family:calibri,sans-serif;color:rgb(79,129,189)" class="">> }</span></div>The trip count of 2 should be valid for x in [0,6]. </div></div></div></blockquote><div><br class=""></div><div>It is not clear to me why the trip count of 2 isn’t *always* valid.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">If SCEV doesn't catch it with, say GVN and appropriate matching conditions, it could be improved.</div><div class="">CMIIW, I don't think LLVM goes out of the way to opportunistically version the loop by inserting if check(s) and then unroll it.</div></div></div></blockquote><div><br class=""></div><div>We shouldn’t need any runtime check to derive the trip count here.</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">-Kevin</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Sep 16, 2016 at 1:27 PM, Sanjoy Das via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Deepali,<br class="">
<br class="">
SCEV reports the backedge taken count as "((-1 * (sext i32 (3 + %x) to<br class="">
i64))<nsw> + ((sext i32 (3 + %x) to i64) smax (sext i32 (6 + %x) to<br class="">
i64)))", so symbolically it does have an answer.<br class="">
<br class="">
Ideally SCEV should be able to exploit <nsw> on (3 + %x) and (6 + %x)<br class="">
to fold the expression above to "3", but due to some systemic issues<br class="">
SCEV can't exploit <nsw> as aggressively as we should.<br class="">
<br class="">
Without exploiting <nsw> the trip count is 2^32, which does not fit in<br class="">
an 32 bit unsigned integer.  This is why getSmallConstantTripCount<br class="">
returns 0.<br class="">
<br class="">
Does this answer your question?<br class="">
<br class="">
-- Sanjoy<div class="HOEnZb"><div class="h5"><br class="">
______________________________<wbr class="">_________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
</div></div></blockquote></div><br class=""></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></body></html>