Book contents
- Frontmatter
- Contents
- Preface
- Part I Fundamentals of Compilation
- Part II Advanced Topics
- 13 Garbage Collection
- 14 Object-Oriented Languages
- 15 Functional Programming Languages
- 16 Polymorphic Types
- 17 Dataflow Analysis
- 18 Loop Optimizations
- 19 Static Single-Assignment Form
- 20 Pipelining and Scheduling
- 21 The Memory Hierarchy
- Appendix: Tiger Language Reference Manual
- Bibliography
- Index
18 - Loop Optimizations
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- Part I Fundamentals of Compilation
- Part II Advanced Topics
- 13 Garbage Collection
- 14 Object-Oriented Languages
- 15 Functional Programming Languages
- 16 Polymorphic Types
- 17 Dataflow Analysis
- 18 Loop Optimizations
- 19 Static Single-Assignment Form
- 20 Pipelining and Scheduling
- 21 The Memory Hierarchy
- Appendix: Tiger Language Reference Manual
- Bibliography
- Index
Summary
loop: a series of instructions that is repeated until a terminating condition is reached
Webster's DictionaryLoops are pervasive in computer programs, and a great proportion of the execution time of a typical program is spent in one loop or another. Hence it is worthwhile devising optimizations to make loops go faster. Intuitively, a loop is a sequence of instructions that ends by jumping back to the beginning. But to be able to optimize loops effectively we will use a more precise definition.
A loop in a control-flow graph is a set of nodes S including a header node h with the following properties:
From any node in S there is a path of directed edges leading to h.
There is a path of directed edges from h to any node in S.
There is no edge from any node outside S to any node in S other than h.
Thus, the dictionary definition (from Webster's) is not the same as the technical definition.
Figure 18.1 shows some loops. A loop entry node is one with some predecessor outside the loop; a loop exit node is one with a successor outside the loop. Figures 18.1c, 18.1d, and 18.1e illustrate that a loop may have multiple exits, but may have only one entry. Figures 18.1e and 18.1f contain nested loops.
REDUCIBLE FLOW GRAPHS
A reducible flow graph is one in which the dictionary definition of loop corresponds more closely to the technical definition; but let us develop a more precise definition.
- Type
- Chapter
- Information
- Modern Compiler Implementation in C , pp. 410 - 432Publisher: Cambridge University PressPrint publication year: 1997