<div dir="ltr">Hi Bodhi,<br><div><br></div><div>Well, probably you can't get the bounds because your loops are not rotated [1]</div><div>You can get that with -loop-rotate pass.</div><div><br></div><div>FWIW, this is required by `getInductionVariable()` [2]</div><div>as if the loop is not rotated, you won't have the comparison on the latch. In general, I think that `getInductionVariable()` is weird, which</div><div>results in e.g., some loop optimizations writing _their own_ getInductionVariable() because the "canonical" one can't do the job. For example, loop interchange [3]</div><div><br></div><div>Best,</div><div>Stefanos</div><div><br></div><div>[1] 

<a href="https://llvm.org/docs/LoopTerminology.html#rotated-loops">https://llvm.org/docs/LoopTerminology.html#rotated-loops</a>

</div><div>[2] 

<a href="https://github.com/llvm/llvm-project/blob/95d13c01ecba5c9dba8ea1bd875c4179cbaea9e2/llvm/lib/Analysis/LoopInfo.cpp#L299">https://github.com/llvm/llvm-project/blob/95d13c01ecba5c9dba8ea1bd875c4179cbaea9e2/llvm/lib/Analysis/LoopInfo.cpp#L299</a>

</div><div>[3] <a href="https://github.com/llvm/llvm-project/blob/95d13c01ecba5c9dba8ea1bd875c4179cbaea9e2/llvm/lib/Transforms/Scalar/LoopInterchange.cpp#L298">https://github.com/llvm/llvm-project/blob/95d13c01ecba5c9dba8ea1bd875c4179cbaea9e2/llvm/lib/Transforms/Scalar/LoopInterchange.cpp#L298</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Στις Δευ, 22 Φεβ 2021 στις 6:48 μ.μ., ο/η bodhisatwa via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> έγραψε:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I am trying to test out the getBounds() method from LoopInfo. However, the <br>
method doesn't seem to obtain the bounds of simple loops like -<br>
<br>
        for (int j = 0; j < 10; j ++)<br>
            B[j] = 6;<br>
<br>
        int i = 10, j = 2,<br>
<br>
        while ( i != j)<br>
              j++;<br>
<br>
  My code snippet in the function pass is as follows (which gives the output <br>
as "No value for loop bounds" for all the loops):<br>
<br>
       LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();<br>
<br>
       for (auto loop = LI.begin(), e = LI.end(); loop != e; ++loop )<br>
       {<br>
           ScalarEvolution *SE = <br>
&getAnalysis<ScalarEvolutionWrapperPass>().getSE();<br>
           auto b = (*loop)->getBounds(*SE);<br>
<br>
           if (!b.hasValue())<br>
                {<br>
                   errs() << "No value for loop bounds\n";<br>
                }<br>
       }<br>
<br>
  Is there something that I am missing here?<br>
<br>
<br>
  Thanks,<br>
  Bodhi<br>
<br>
_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>