# Ch10 - 1 ! Code Optimization! Chapter 9&quot; (1st ed....

This preview shows pages 1–12. Sign up to view the full content.

1 Code Optimization Chapter 9 (1 st ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2011

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 The Code Optimizer • Control fow analysis: control fow graph • Data-fow analysis • TransFormations ±ront end Code generator 2 The Code Optimizer • Control fow analysis: control fow graph • Data-fow analysis • TransFormations ±ront end Code generator Code
3 Determining Loops in Flow Graphs: Dominators • Dominators: d dom n – Node d of a CFG dominates node n if every path from the initial node of the CFG to n goes through d – The loop entry dominates all nodes in the loop • The immediate dominator m of a node n is the last dominator on the path from the initial node to n – If d ! n and d dom n then d dom m

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Dominator Trees 1 2 3 4 5 6 7 8 9 10 1 2 3 4 6 5 7 8 9 10 CFG Dominator tree
5 Natural Loops • A back edge is is an edge a " b whose head b dominates its tail a • Given a back edge n " d – The natural loop consists of d plus the nodes that can reach n without going through d – The loop header is node d • In other words – A natural loop must have a single-entry node d – There must be a back edge that enters node d

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 Natural Inner/Outer Loops • Unless two loops have the same header, they are disjoint or one is nested within the other • A nested loop is an inner loop if it contains no other loops • A loop is an outer loop if it is not contained within another loop
7 Natural Inner Loops Example 1 2 3 4 5 6 7 8 9 10 1 2 3 4 6 5 7 8 9 10 CFG Dominator tree Natural loop for 7 dom 10 Natural loop for 3 dom 4 Natural loop for 4 dom 7

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 Natural Outer Loops Example 1 2 3 4 5 6 7 8 9 10 1 2 3 4 6 5 7 8 9 10 CFG Dominator tree Natural loop for 1 dom 9 Natural loop for 3 dom 8
9 Pre-Headers • To facilitate loop transformations, a compiler often adds a preheader to a loop • Code motion, strength reduction, and other loop transformations populate the preheader Header Header Preheader

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
10 Reducible Flow Graphs 1 2 3 4 Example of a reducible CFG 1 2 3 Example of a nonreducible CFG Reducible graph = disjoint partition in forward and back edges such that the forward edges form an acyclic (sub)graph
11 Global Data-Flow Analysis • To apply global optimizations on basic blocks, data-fow inFormation is collected by solving systems of data-fow equations • Suppose we need to determine the

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/01/2012 for the course COP 5621 taught by Professor Vanengelen during the Spring '11 term at FSU.

### Page1 / 27

Ch10 - 1 ! Code Optimization! Chapter 9&quot; (1st ed....

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online