<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>We have the predicated backedge taken count, so the loop should be vectorizable.</p>
<p>I think the fact that getOrCreateTripCount doesn't use the predicated backedge taken count  is probably a bug (and might blow up in certain conditions).</p>
<p><br>
</p>
<p>-Silviu</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Friedman, Eli via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Sent:</b> 22 May 2017 18:33:02<br>
<b>To:</b> Alex Susu; llvm-dev<br>
<b>Subject:</b> Re: [llvm-dev] Computing loop trip counts with Scalar evolution</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On 5/18/2017 11:30 AM, Alex Susu via llvm-dev wrote:<br>
>   Hello.<br>
>     I tried to get the trip count of a loop with Scalar evolution. I <br>
> got inspired from <br>
> <a href="http://stackoverflow.com/questions/13834364/how-to-get-loop-bounds-in-llvm">
http://stackoverflow.com/questions/13834364/how-to-get-loop-bounds-in-llvm</a> <br>
> .<br>
>     However the analysis described there doesn't work well for the <br>
> second inner loop of thes function below (although if we declare Bcols <br>
> a short it works well):<br>
>       void MatMul(int Arows, int Acols, int Brows, int Bcols) {<br>
>         short i, j, k;<br>
>         for (i = 0; i < Arows; ++i) {<br>
>           for (j = 0; j < Bcols; ++j) {<br>
>             C[i][j] = 0;<br>
>             for (k = 0; k < Acols; ++k) {<br>
>               C[i][j] += A[i][k] * B[j][k];<br>
>             }<br>
>           }<br>
>         }<br>
>       }<br>
><br>
<br>
Your function is weird because the compiler can't prove whether the <br>
induction variables overflow.  Here's the output of "clang -O2 <br>
-emit-llvm -S | opt -analyze -scalar-evolution":<br>
<br>
Determining loop execution counts for: @MatMul<br>
Loop %for.body13: Unpredictable backedge-taken count.<br>
Loop %for.body13: Unpredictable max backedge-taken count.<br>
Loop %for.body13: Predicated backedge-taken count is (-1 + %Acols)<br>
  Predicates:<br>
     {1,+,1}<%for.body13> Added Flags: <nssw><br>
<br>
Loop %for.body6: Unpredictable backedge-taken count.<br>
Loop %for.body6: Unpredictable max backedge-taken count.<br>
Loop %for.body6: Predicated backedge-taken count is (-1 + %Bcols)<br>
  Predicates:<br>
     {1,+,1}<%for.body6> Added Flags: <nssw><br>
<br>
Loop %for.cond2.preheader: Unpredictable backedge-taken count.<br>
Loop %for.cond2.preheader: Unpredictable max backedge-taken count.<br>
Loop %for.cond2.preheader: Predicated backedge-taken count is (-1 + %Arows)<br>
  Predicates:<br>
     {1,+,1}<%for.cond2.preheader> Added Flags: <nssw><br>
<br>
-Eli<br>
<br>
<br>
-- <br>
Employee of Qualcomm Innovation Center, Inc.<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
llvm-dev@lists.llvm.org<br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</div>
</span></font>IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use
 it for any purpose, or store or copy the information in any medium. Thank you.
</body>
</html>