<div dir="ltr"><div>> <span style="color:rgb(79,129,189);font-family:calibri,sans-serif;font-size:14.6667px">int mat[9][9][9];<br></span>> <span style="color:rgb(79,129,189);font-family:calibri,sans-serif;font-size:11pt">for (p = (x+1) ; p < (x+3) ;p++)</span></div><div><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"times new roman",serif"><span style="font-size:11pt;font-family:calibri,sans-serif;color:rgb(79,129,189)">>    mat[x][p-1][i] = mat[x][p-1][i] + 5;<u></u><u></u></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"times new roman",serif"><span style="font-size:11pt;font-family:calibri,sans-serif;color:rgb(79,129,189)">> }</span></p>The trip count of 2 should be valid for x in [0,6]. If SCEV doesn't catch it with, say GVN and appropriate matching conditions, it could be improved.</div><div>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><br></div><div>-Kevin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 16, 2016 at 1:27 PM, Sanjoy Das via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Deepali,<br>
<br>
SCEV reports the backedge taken count as "((-1 * (sext i32 (3 + %x) to<br>
i64))<nsw> + ((sext i32 (3 + %x) to i64) smax (sext i32 (6 + %x) to<br>
i64)))", so symbolically it does have an answer.<br>
<br>
Ideally SCEV should be able to exploit <nsw> on (3 + %x) and (6 + %x)<br>
to fold the expression above to "3", but due to some systemic issues<br>
SCEV can't exploit <nsw> as aggressively as we should.<br>
<br>
Without exploiting <nsw> the trip count is 2^32, which does not fit in<br>
an 32 bit unsigned integer.  This is why getSmallConstantTripCount<br>
returns 0.<br>
<br>
Does this answer your question?<br>
<br>
-- Sanjoy<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div>