<div dir="ltr">I am primarily interested in phi nodes and their induction variables, in ValueTracking file there is an analysis of them, but if the upper bound is inf, it is not working?<br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-08-07 11:41 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>So, it is not supported to determine by this instruction : %cmp = icmp slt i32 %i.03, 99, <br></div>that %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ] has <br>a range [0, 99]?<br><br></div>And what is then a correct way to get such an info, that you sent ( with more specified ranges)? ...seems that appropriate method for it is not in LazyValueInfo class.<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-08-07 11:34 GMT+02:00 Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Mon, Aug 7, 2017 at 2:14 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>
> I am trying to print it like this (maybe here is smth wrong?)<br>
><br>
><br>
> LazyValueInfo &LV = getAnalysis<LazyValueInfoWrapp<wbr>erPass>().getLVI();<br>
> DominatorTree &DT =<br>
> getAnalysis<DominatorTreeWrapp<wbr>erPass>().getDomTree();<br>
> LV.printLVI(F, DT, llvm::outs());<br>
<br>
</span>The value analysis in llvm is lazy (hence, LVI), so you're trying to<br>
print an empty cache, I guess.<br>
<span><br>
> for (BasicBlock &BB : F) {<br>
> for (Instruction &I : BB) {<br>
> if (Value* v = dyn_cast<Value>(&I))<br>
> if (v->getType()->isIntegerTy()) {<br>
> ConstantRange r = LV.getConstantRange(v, &BB, &I);<br>
> I.dump();<br>
> printf("LOWER VALUE : %llu\n",r.getLower().getRawDat<wbr>a());<br>
> printf("UPPER VALUE : %llu\n",r.getUpper().getRawDat<wbr>a());<br>
> }<br>
> }<br>
<br>
</span>About your other question, "the value range pass was not able to<br>
<span>determine any size, even of the induction variable, is it a correct<br>
</span>behavior?". Yes, returning a conservative answer is always correct,<br>
but not optimal.<br>
<br>
As reference, a more sophisticated range analysis finds the following<br>
ranges for your IR:<br>
<br>
[0, +inf] %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]<br>
[0, +inf] %s.02 = phi i32 [ 0, %entry ], [ %add2, %for.body ]<br>
[0, +inf] %j.01 = phi i32 [ 0, %entry ], [ %add1, %for.body ]<br>
[0, +inf] %add = add nsw i32 %j.01, %i.03<br>
[1, +inf] %add1 = add nsw i32 %add, 1<br>
[1, +inf] %add2 = add nsw i32 %s.02, %add1<br>
[1, +inf] %inc = add nsw i32 %i.03, 1<br>
[2, +inf] %add3 = add nsw i32 %add2, %add1<br>
<br>
<br>
--<br>
Davide<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>