Hi,
I am trying to use the forest populated by LoopAnalysis::run. At the end of the function I am printing out the loop headers in forest like so:
for (auto &[root, nodes] : forest) {
std::cout << "Loop header: " << root->getName() << std::endl;
for (auto *node : nodes) {
std::cout << " Child: " << node->getName() << std::endl;
}
}
But it seems that some loop headers are not being populated in forest, consider these 3 nested loops:
define i32 @src() {
entry:
br label %for.body
for.cond.cleanup:
ret i32 undef
for.body:
br label %for.body.inner
for.cond.cleanup.inner:
br i1 undef, label %for.cond.cleanup, label %for.body
for.cond.cleanup.inner.inner:
br i1 undef, label %for.cond.cleanup.inner, label %for.body.inner
for.body.inner:
br label %for.body.inner.inner
for.body.inner.inner:
br i1 undef, label %for.cond.cleanup.inner.inner, label %for.body.inner.inner
}
The print out of forest gives
Loop header: %for.body.inner
Child: %for.body.inner.inner
Child: %for.cond.cleanup.inner.inner
Loop header: %for.body
Child: %for.body.inner
Child: %for.cond.cleanup.inner
so the innermost loop %for.body.inner.inner is not populated as a loop header.
Is there something missing in the logic here?
Or is forest supposed to look like this?
You can also try running llvms loop analysis pass which correctly identifies 3 loop headers:
opt -passes='print<loops>' test.ll
I am asking this in the contex of #1300. I am using forest to obtain loop headers which individual unroll bounds are applied to in order. I was expecting all the loop headers to be available there, but it seems like they are not for some cases. I have a temporary fix for now but I am not sure if this is even the correct way of doing such a thing.
Thanks!
Hi,
I am trying to use the forest populated by
LoopAnalysis::run. At the end of the function I am printing out the loop headers inforestlike so:But it seems that some loop headers are not being populated in
forest, consider these 3 nested loops:The print out of
forestgivesso the innermost loop
%for.body.inner.inneris not populated as a loop header.Is there something missing in the logic here?
Or is
forestsupposed to look like this?You can also try running llvms loop analysis pass which correctly identifies 3 loop headers:
opt -passes='print<loops>' test.llI am asking this in the contex of #1300. I am using
forestto obtain loop headers which individual unroll bounds are applied to in order. I was expecting all the loop headers to be available there, but it seems like they are not for some cases. I have a temporary fix for now but I am not sure if this is even the correct way of doing such a thing.Thanks!