Ch10 - 1 ! Code Optimization! Chapter 9" (1st ed....

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

View Full Document Right Arrow Icon
1 Code Optimization Chapter 9 (1 st ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2011
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
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
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
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" (1st ed....

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online