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)
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);
errs() << "No value for loop bounds\n";
Is there something that I am missing here?
Well, probably you can’t get the bounds because your loops are not rotated 
You can get that with -loop-rotate pass.
FWIW, this is required by
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 
Στις Δευ, 22 Φεβ 2021 στις 6:48 μ.μ., ο/η bodhisatwa via llvm-dev <email@example.com> έγραψε:
JFYI, the infrastructure on Loop itself is very very limited. Honestly, it probably shouldn't exist at all.
ScalarEvolution exists to analyze loops. In particular, it can compute symbolic execute counts for a much much broader family of loops.
Without knowing your use case, I can't say for sure, but I suspect you want to be using ScalarEvolution.