question on loop representation in CFGs (-fdump-tree-cfg)

Elena Vorobev
Tue Jun 17 08:38:00 GMT 2008


I have a question on loop representation in CFGs (which I get when using
the -fdump-tree-cfg option). On the page describing gcc internals
(, the
text says: "In general, a natural loop has one entry block (header) and
possibly several back edges (latches) leading to the header from the
inside of the loop. Loops with several latches may appear if several
loops share a single header, or if there is a branching in the middle of
the loop. The representation of loops in GCC however allows only loops
with a single latch. During loop analysis, headers of such loops are
split and forwarder blocks are created in order to disambiguate their

Assuming a function sampleFunc() uses structured statements only[*],
will the loops in the associated CFG always be already in the form as
described above (i.e. natural loops with a single latch)? If not, which
would be the right steps to get such one? The main problem I have is,
that I actually don't know at which stage (while processing the input
file) the CFG is created. Though the semantics should remain the same,
as far as I understand, the CFG representation of a function might (or
will?) be different e.g. before and after some optimizations. That's why
it seems to me being important to know whether the CFG is created before
or after the "loop analysis" mentioned in the text above.

[*] According to a few other documents I read on that subject, for
functions using structured statetements only, the resulting CFG should
always be reducible, so that if loops exist, they should be "natural".


More information about the Gcc-help mailing list