<div dir="ltr">Also, even when not using canonical induction variables, and extracting max backedge taken count, then I can't determine to which phi instruction ( if I have many of them in cycle) this backedge taken count relates to (as Loop can only provide me with canonical variable and SCEV gives a description of PHI). Or maybe again I didn't find an appropriate method to extract this phi node, which gives this count.<br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-08-10 10:00 GMT+02:00 Anastasiya Ruzhanskaya <span dir="ltr"><<a href="mailto:anastasiya.ruzhanskaya@frtk.ru" target="_blank">anastasiya.ruzhanskaya@frtk.ru</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Maybe you, as a person connected with this theme, have some recommendations? Analyzing SCEV didn't help me, as I am not able to extract information, that is crucial for me.<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-08-10 9:55 GMT+02:00 Anastasiya Ruzhanskaya <span dir="ltr"><<a href="mailto:anastasiya.ruzhanskaya@frtk.ru" target="_blank">anastasiya.ruzhanskaya@frtk.<wbr>ru</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi!<br></div>By only two cases I mean , that in exiting block when computing the condition related to PHI node I can expect only icmp on one of incoming values or on phi node itself... I tried to come up with some more complex examples but I always receive only these two cases, that is why I am asking.<br><br></div>This problem still relates to the problem of all induction, cumulative and so on variables in loop. SCEV didn't help me, as it doesn't provide me with the value against which I am comparing when exiting, and when it cannot detect loop trip count directly I need this "exiting value". That is why I am searching for all compare instructions in exiting blocks that are using either "phi" itself or "incoming value". <br></div><div class="m_520249425532768103HOEnZb"><div class="m_520249425532768103h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-08-10 9:47 GMT+02:00 Sanjoy Das <span dir="ltr"><<a href="mailto:sanjoy@google.com" target="_blank">sanjoy@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It may be helpful to see the incoming value as the incoming value of<br>
the "next" PHI (i.e. the instance of the PHI node on the next<br>
iteration).  With that interpretation in mind, you can see that<br>
comparing the PHI node itself is equivalent to:<br>
<br>
do {<br>
  ...<br>
  // I is the value that becomes the PHI node<br>
} while (I++ < N);<br>
<br>
and comparing with the incoming value of the PHI is equivalent to:<br>
<br>
do {<br>
  ...<br>
} while (++I < N);<br>
<br>
<br>
I can't think of any fundamental reason why one would be preferred for<br>
increasing induction variables and the other would be preferred for<br>
decreasing induction variables.  I suspect what you're seeing is just<br>
an artifact of how clang lowers these loops.<br>
<br>
I'm also not sure what you mean by "I can have only two cases".   Loop<br>
backedge conditions can be arbitrarily complex, if that's what you're<br>
asking.<br>
<br>
-- Sanjoy<br>
<div><div class="m_520249425532768103m_-3355567381636401230h5"><br>
<br>
On Thu, Aug 10, 2017 at 12:34 AM, Anastasiya Ruzhanskaya via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> Hello,<br>
> I have one more question about how phi nodes and their corresponding ICmp<br>
> instructions are associated. maybe it is simple, but at first I thought that<br>
> we always compare against one of incoming value. Is it true that  I can have<br>
> only  two cases:<br>
> %indvars.iv = phi i64 [ %indvars.iv.next, %1 ], [ 0, %0 ]<br>
> ...<br>
> %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1<br>
> %exitcond = icmp eq i64 %indvars.iv.next, 32<br>
><br>
><br>
> and<br>
><br>
> %i.11 = phi i32 [ %<a href="http://i.11.be" rel="noreferrer" target="_blank">i.11.be</a>, %.backedge ], [ 32, %1 ]<br>
> ...<br>
> %13 = icmp sgt i32 %i.11, 3<br>
> ?<br>
> In the first one we always have icmp on the incoming value after addition,<br>
> multiplication and so on.<br>
> In the second - we compare at first against our phi variable and then<br>
> perform operations. I have noticed, that the first case correspond to "up"<br>
> operations - +=, *= ans do on, the second - to "down" : -=, /= and so on.<br>
> But maybe it depends on logic of the cycle too... So, are their two cases :<br>
> comparing in exiting block against PHI variable or against one of its'<br>
> incoming value?<br>
><br>
</div></div>> ______________________________<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>
><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>