|
|
8.6.6 Finding Natural Loops Efficiently
We introduce one more definition - a backwards edge.
To find the loops of a program efficiently:
- Compute a depth-first order (DFO). The backwards edges
are those whose heads precede their tails in the DFO.
- Compute Dominators. The back edges are the backwards edges whose heads dominate their tails.
- For each back edge, compute the natural loop.
These steps find the natural loops of a program in an efficient way.
|