[llvm-dev] Obtaining bounds of loops
Stefanos Baziotis via llvm-dev
llvm-dev at lists.llvm.org
Mon Feb 22 10:32:24 PST 2021
Hi Bodhi,
Well, probably you can't get the bounds because your loops are not rotated
[1]
You can get that with -loop-rotate pass.
FWIW, this is required by `getInductionVariable()` [2]
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
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]
Best,
Stefanos
[1] https://llvm.org/docs/LoopTerminology.html#rotated-loops
[2]
https://github.com/llvm/llvm-project/blob/95d13c01ecba5c9dba8ea1bd875c4179cbaea9e2/llvm/lib/Analysis/LoopInfo.cpp#L299
[3]
https://github.com/llvm/llvm-project/blob/95d13c01ecba5c9dba8ea1bd875c4179cbaea9e2/llvm/lib/Transforms/Scalar/LoopInterchange.cpp#L298
Στις Δευ, 22 Φεβ 2021 στις 6:48 μ.μ., ο/η bodhisatwa via llvm-dev <
llvm-dev at lists.llvm.org> έγραψε:
> Hi,
>
> I am trying to test out the getBounds() method from LoopInfo. However, the
> method doesn't seem to obtain the bounds of simple loops like -
>
> for (int j = 0; j < 10; j ++)
> B[j] = 6;
>
> int i = 10, j = 2,
>
> while ( i != j)
> j++;
>
> My code snippet in the function pass is as follows (which gives the
> output
> as "No value for loop bounds" for all the loops):
>
> LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
>
> for (auto loop = LI.begin(), e = LI.end(); loop != e; ++loop )
> {
> ScalarEvolution *SE =
> &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
> auto b = (*loop)->getBounds(*SE);
>
> if (!b.hasValue())
> {
> errs() << "No value for loop bounds\n";
> }
> }
>
> Is there something that I am missing here?
>
>
> Thanks,
> Bodhi
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210222/8e426d0e/attachment.html>
More information about the llvm-dev
mailing list