Skip to content

Commit f3b7523

Browse files
committed
[docs] Reword documentation in terms of SCCs not cycles
Given the example: header: br i1 %c, label %next, label %header next: br i1 %c2, label %exit, label %header We end up with a loop containing both header and next. Given that, the describing the loop in terms of cycles is confusing since we have multiple distinct cycles within a single Loop. Standardize on the SCC to clarify. Differential Revision: https://reviews.llvm.org/D65299 llvm-svn: 367440
1 parent 8d76284 commit f3b7523

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

llvm/docs/LoopTerminology.rst

+15-8
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,25 @@ Loops are a core concept in any optimizer. This page spells out some
1212
of the common terminology used within LLVM code to describe loop
1313
structures.
1414

15-
First, let's start with the basics. In LLVM, a Loop is a cycle within
16-
the control flow graph (CFG) where there exists one block (the loop
17-
header block) which dominates all other blocks within the cycle.
15+
First, let's start with the basics. In LLVM, a Loop is a set of basic
16+
blocks that form a strongly connected component (SCC) in the Control
17+
Flow Graph (CFG) where there exists a dedicated entry/header block that
18+
dominates all other blocks within the loop. Thus, without leaving the
19+
loop, one can reach every block in the loop from the header block and
20+
the header block from every block in the loop.
1821

1922
Note that there are some important implications of this definition:
2023

21-
* Not all cycles are loops. There exist cycles that do not meet the
24+
* Not all SCCs are loops. There exist SCCs that do not meet the
2225
dominance requirement and such are not considered loops.
2326

24-
* Loops can contain non-loop cycles and non-loop cycles may contain
27+
* Loops can contain non-loop SCCs and non-loop SCCs may contain
2528
loops. Loops may also contain sub-loops.
2629

30+
* A header block is uniquely associated with one loop. There can be
31+
multiple SCC within that loop, but the strongly connected component
32+
(SCC) formed from their union must always be unique.
33+
2734
* Given the use of dominance in the definition, all loops are
2835
statically reachable from the entry of the function.
2936

@@ -51,9 +58,9 @@ of the other.
5158

5259
Exiting Block - A basic block contained within a given loop which has
5360
at least one successor outside of the loop and one successor inside the
54-
loop. (The latter is required for the block to be contained within the
55-
cycle which makes up the loop.) That is, it has a successor which is
56-
an Exit Block.
61+
loop. (The latter is a consequence of the block being contained within
62+
an SCC which is part of the loop.) That is, it has a successor which
63+
is an Exit Block.
5764

5865
Exit Block - A basic block outside of the associated loop which has a
5966
predecessor inside the loop. That is, it has a predecessor which is

0 commit comments

Comments
 (0)