<div dir="ltr">Do you think, that the best way - is to totally restrict myself with loop tipe and give up the idea of trying to get the info from SCEV?<br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-08-14 8:48 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"><div><div><div><div><div><div><div><div><div><div>Yes,<br></div>basically my problem is that I want to reduce a bit size of induction variables as i and maybe some reduction one in a loop. <br>1) I wanted to use SCEV at first, but then realized that this is a real waste of time of finding the exact phi node that led to this trip count. <br></div>   1.1) Even if I can determine phi, and loop was like for (i = 1000; 5*i > 100; i--) - my trip count is not the range of i. <br></div>2) I wanted to track only exiting blocks and values with which phi nodes are compared there - again there too tiny cases, where i can change unpredictable inside a cycle and I will not detect it or even the<br></div>    example above : I have to track these arithmetic expressions.<br><br></div>By now, I decided to restrict myself with only cycles of type for (i = 0; i <N ; i++/i--/i+=2/i*=2 ) and so on + the condition that there no more users of these phi except addition, multiplication and so on and they should be definitely compared with some value in exiting block.<br><br></div>The indvars2 pass, that was eliminated some years ago, seems to be perfect solution, but seems, that this is a not good decision as inserting it and updating llvm and this pass every time accordingly.<br></div>So, task is simple: for integers track the range of phi ( llvm's vrp can't do this). Also.<br><br></div>for (i = 0; i < N;i++)<br></div> - when I know some bits in N, I can also try to find out the range of i, what llvm can't do.<br><br></div>That is the problem:)<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-08-14 5:00 GMT+02:00 Sanjoy Das <span dir="ltr"><<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.<wbr>com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span><br>
On Sun, Aug 13, 2017 at 5:58 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>
> And still, aren't there any possibilities to find that phi node, that led<br>
> SCEV to compute max trip count?<br>
<br>
</span>So there is no good  answer to your question since in most cases SCEV<br>
does not directly look at PHI nodes (or expressions based off of the<br>
PHI node).  It converts PHI nodes and related expressions into SCEV<br>
expressions and computes trip counts off of these SCEV expressions;<br>
and there is no reliable way to map a SCEV expression back into a PHI<br>
node (though it may be possible in some cases).<br>
<br>
However this is sounding like an XY problem (<a href="http://xyproblem.info/" rel="noreferrer" target="_blank">http://xyproblem.info/</a>)<br>
:)  Do you mind taking a step back and giving us some information<br>
about the broader picture?<br>
<span><br>
> 2017-08-13 14:55 GMT+02:00 Anastasiya Ruzhanskaya<br>
</span><span>>> To continue this topic:<br>
>> sometimes SCEV's behavior is rather controversial : for loops with i<br>
>> changing as i \=2 for example, he can't figure what the type of expressions<br>
>> is, but surprisingly can determine max trip count. Shouldn't it be able to<br>
>> detect or not detect  these parameters at the same time?<br>
<br>
</span>SCEV expressions cannot represent recurrences that are are divided by<br>
some amount every iteration.  And while not being able to represent<br>
induction variables as SCEV expressions does make it more difficult to<br>
compute trip counts, SCEV has some other patterns it tries to<br>
recognize even in cases where the relevant expressions could not be<br>
mapped to neat SCEV add recurrences.  Another example: SCEV can<br>
compute the trip counts for strlen-like loops:<br>
<a href="https://godbolt.org/g/hWtEWm" rel="noreferrer" target="_blank">https://godbolt.org/g/hWtEWm</a><br>
<span class="m_-1974098338659075761HOEnZb"><font color="#888888"><br>
-- Sanjoy<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>