[LLVMdev] Loop depth concept

Wojciech Matyjewicz wmatyjewicz at fastmail.fm
Fri Mar 14 12:27:55 PDT 2008


Hi,

I'm working on a simple data dependence analysis pass. I think it would
be more natural (in the API and internally) if loops in nests were
numbered from 0 than, as it's currently done, from 1. For example, in
the former case the loop depth could be directly used to index a
direction vector. IMHO it would be more clear in general, not only in
the context of my project. Off course, it's only a cosmetic proposition
and I'm not going to insist on that change.

Currently, there are 2 methods to determine the depth of something:
a) unsigned LoopInfo::getLoopDepth(BlockT *BB);
   // Return the loop nesting level of the specified block.
b) unsigned Loop::getLoopDepth()
   // Return the nesting level of this loop.

The reason why numbering in b) starts from 1 is to be consistent with
numbering in a) (which starts from 0) --- the depth of BB is the same as
the depth of loop it belongs to. But is it really that important?
Currently, b) isn't used anywhere outside the LoopInfo.h.

Starting numbering from 0 in both cases will also be consistent, but in
other way;) "depth" may be defined as the number of loops a BB/loop is
contained in.

What do you think?

Wojtek



More information about the llvm-dev mailing list