- 1 - Dominator Tree BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 BB0 BB1 BB2BB3 BB4 BB6 BB5 BB7 BBDOM0 10,1 20,1,2 30,1,3 BBDOM 40,1,3,4 50,1,3,5 60,1,3,6 70,1,7 Dom.

Slides:



Advertisements
Similar presentations
SSA and CPS CS153: Compilers Greg Morrisett. Monadic Form vs CFGs Consider CFG available exp. analysis: statement gen's kill's x:=v 1 p v 2 x:=v 1 p v.
Advertisements

1 SSA review Each definition has a unique name Each use refers to a single definition The compiler inserts  -functions at points where different control.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) SSA Guo, Yao.
SSA.
CS412/413 Introduction to Compilers Radu Rugina Lecture 37: DU Chains and SSA Form 29 Apr 02.
SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Binary Search Tree A running demonstration of binary search.
Computer Science 313 – Advanced Programming Topics.
Components of representation Control dependencies: sequencing of operations –evaluation of if & then –side-effects of statements occur in right order Data.
Stanford University CS243 Winter 2006 Wei Li 1 SSA.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Static Single Assignment John Cavazos.
Program Representations. Representing programs Goals.
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
Advanced Compiler Design – Assignment 1 SSA Construction & Destruction Michael Fäs (Original Slides by Luca Della Toffola)
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
Representing programs Goals. Representing programs Primary goals –analysis is easy and effective just a few cases to handle directly link related things.
CS745: SSA© Seth Copen Goldstein & Todd C. Mowry Static Single Assignment.
Insert A tree starts with the dummy node D D 200 D 7 Insert D
Lecture #17, June 5, 2007 Static Single Assignment phi nodes Dominators Dominance Frontiers Dominance Frontiers when inserting phi nodes.
CS 201 Compiler Construction
Class canceled next Tuesday. Recap: Components of IR Control dependencies: sequencing of operations –evaluation of if & then –side-effects of statements.
Insertion into a B+ Tree Null Tree Ptr Data Pointer * Tree Node Ptr After Adding 8 and then 5… 85 Insert 1 : causes overflow – add a new level * 5 * 158.
1 CS 201 Compiler Construction Lecture 9 Static Single Assignment Form.
Lecture 17 Non-Linear data structures Richard Gesick.
Computer Science: A Structured Programming Approach Using C Trees Trees are used extensively in computer science to represent algebraic formulas;
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Static Single Assignment John Cavazos.
U NIVERSITY OF M ASSACHUSETTS, A MHERST D EPARTMENT OF C OMPUTER S CIENCE Advanced Compilers CMPSCI 710 Spring 2003 Dominators, etc. Emery Berger University.
Data Structures: Advanced Damian Gordon. Advanced Data Structure We’ll look at: – Linked Lists – Trees – Stacks – Queues.
Computer Science 112 Fundamentals of Programming II Introduction to Trees.
Generating SSA Form (mostly from Morgan). Why is SSA form useful? For many dataflow problems, SSA form enables sparse dataflow analysis that –yields the.
Building SSA Form (A mildly abridged account) For the full story, see the lecture notes for COMP 512 (lecture 8) and.
Dead Code Elimination This lecture presents the algorithm Dead from EaC2e, Chapter 10. That algorithm derives, in turn, from Rob Shillner’s unpublished.
CS 614: Theory and Construction of Compilers Lecture 15 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
BINARY TREES A BINARY TREE t IS EITHER EMPTY OR CONSISTS OF AN ITEM, CALLED THE ROOT ITEM, AND TWO DISTINCT BINARY TREES, CALLED THE LEFT SUBTREE AND.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 Static Single Assignment John Cavazos.
Building SSA Form, I 1COMP 512, Rice University Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at.
Tree - in “math speak” An ________ graph is a set of vertices/nodes and a set of edges, each edge connects two vertices. Any undirected graph in which.
Dominators and CFGs Taken largely from University of Delaware Compiler Notes.
Loops Simone Campanoni
Graph Search Applications, Minimum Spanning Tree
Fundamentals of Programming II Introduction to Trees
CS 201 Compiler Construction
AVL Tree Example: Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree
Red Black Trees
Efficiently Computing SSA
Design and Analysis of Algorithms
Princeton University Spring 2016
CS 201 Compiler Construction
Factored Use-Def Chains and Static Single Assignment Forms
Taken largely from University of Delaware Compiler Notes
Minimum Spanning Tree.
Instruction Scheduling: Beyond Basic Blocks
Building SSA Form COMP 512 Rice University Houston, Texas Fall 2003
CS 201 Compiler Construction
CSC D70: Compiler Optimization Static Single Assignment (SSA)
Optimizations using SSA
Control Flow Analysis (Chapter 7)
Dominator Tree First BB is the root node, each node
EECS 583 – Class 7 Static Single Assignment Form
Instruction Scheduling: Beyond Basic Blocks
Static Single Assignment
Optimizing Compilers CISC 673 Spring 2011 Static Single Assignment II
EECS 583 – Class 8 Finish SSA, Start on Classic Optimization
EECS 583 – Class 7 Static Single Assignment Form
Taken largely from University of Delaware Compiler Notes
Building SSA Harry Xu CS 142 (b) 04/22/2018.
CSC D70: Compiler Optimization Static Single Assignment (SSA)
Prim’s algorithm for minimum spanning trees
A Series of Slides in 5 Parts Movement 1. DFS
AVL Tree Example: Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree
EMIS 8374 Search Algorithms: DFS Updated 12 February 2004
Presentation transcript:

- 1 - Dominator Tree BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 BB0 BB1 BB2BB3 BB4 BB6 BB5 BB7 BBDOM0 10,1 20,1,2 30,1,3 BBDOM 40,1,3,4 50,1,3,5 60,1,3,6 70,1,7 Dom tree First BB is the root node, each node dominates all of its descendants

- 2 - Computing Dominance Frontiers BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 BB0 BB1 BB2BB3 BB4 BB6 BB5 BB7 For each join point X in the CFG For each predecessor of X in the CFG Run up to the IDOM(X) in the dominator tree, adding X to DF(N) for each N between X and IDOM(X)‏ BBDF

- 3 - Phi Node Insertion - Example a = c = b = c = d = a = d = c =d = b = i = a = b = c = i = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 BBDF a = Phi(a,a)‏ b = Phi(b,b)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ i = Phi(i,i)‏ a is defined in 0,1,3 need Phi in 7 then a is defined in 7 need Phi in 1 b is defined in 0, 2, 6 need Phi in 7 then b is defined in 7 need Phi in 1 c is defined in 0,1,2,5 need Phi in 6,7 then c is defined in 7 need Phi in 1 d is defined in 2,3,4 need Phi in 6,7 then d is defined in 7 need Phi in 1 i is defined in BB7 need Phi in BB1 c = Phi(c,c)‏ d = Phi(d,d)‏ a = Phi(a,a)‏ b = Phi(b,b)‏ c = Phi(c,c)‏ d = Phi(d,d)‏

- 4 - Renaming – Example (Initial State)‏ a = c = b = c = d = a = d = c =d = b = i = a = b = c = i = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a = Phi(a,a)‏ b = Phi(b,b)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ i = Phi(i,i)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ a = Phi(a,a)‏ b = Phi(b,b)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0

- 5 - Renaming – Example (After BB0)‏ a = c = b = c = d = a = d = c =d = b = i = a0 = b0 = c0 = i0 = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a = Phi(a0,a)‏ b = Phi(b0,b)‏ c = Phi(c0,c)‏ d = Phi(d0,d)‏ i = Phi(i0,i)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ a = Phi(a,a)‏ b = Phi(b,b)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0

- 6 - Renaming – Example (After BB1)‏ a2 = c2 = b = c = d = a = d = c =d = b = i = a0 = b0 = c0 = i0 = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a1 = Phi(a0,a)‏ b1 = Phi(b0,b)‏ c1 = Phi(c0,c)‏ d1 = Phi(d0,d)‏ i1 = Phi(i0,i)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ a = Phi(a,a)‏ b = Phi(b,b)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0 a1 b1 c1 d1 i1 a2 c2

- 7 - Renaming – Example (After BB2)‏ a2 = c2 = b2 = c3 = d2 = a = d = c =d = b = i = a0 = b0 = c0 = i0 = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a1 = Phi(a0,a)‏ b1 = Phi(b0,b)‏ c1 = Phi(c0,c)‏ d1 = Phi(d0,d)‏ i1 = Phi(i0,i)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ a = Phi(a2,a)‏ b = Phi(b2,b)‏ c = Phi(c3,c)‏ d = Phi(d2,d)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0 a1 b1 c1 d1 i1 a2 b2 c2 d2 c3

- 8 - Renaming – Example (Before BB3)‏ a2 = c2 = b2 = c3 = d2 = a = d = c =d = b = i = a0 = b0 = c0 = i0 = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a1 = Phi(a0,a)‏ b1 = Phi(b0,b)‏ c1 = Phi(c0,c)‏ d1 = Phi(d0,d)‏ i1 = Phi(i0,i)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ a = Phi(a2,a)‏ b = Phi(b2,b)‏ c = Phi(c3,c)‏ d = Phi(d2,d)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0 a1 b1 c1 d1 i1 a2 c2 This just updates the stack to remove the stuff from the left path out of BB1

- 9 - Renaming – Example (After BB3)‏ a2 = c2 = b2 = c3 = d2 = a3 = d3 = c =d = b = i = a0 = b0 = c0 = i0 = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a1 = Phi(a0,a)‏ b1 = Phi(b0,b)‏ c1 = Phi(c0,c)‏ d1 = Phi(d0,d)‏ i1 = Phi(i0,i)‏ c = Phi(c,c)‏ d = Phi(d,d)‏ a = Phi(a2,a)‏ b = Phi(b2,b)‏ c = Phi(c3,c)‏ d = Phi(d2,d)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0 a1 b1 c1 d1 i1 a2 c2 d3 a3

Renaming – Example (After BB4)‏ a2 = c2 = b2 = c3 = d2 = a3 = d3 = c =d4 = b = i = a0 = b0 = c0 = i0 = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a1 = Phi(a0,a)‏ b1 = Phi(b0,b)‏ c1 = Phi(c0,c)‏ d1 = Phi(d0,d)‏ i1 = Phi(i0,i)‏ c = Phi(c2,c)‏ d = Phi(d4,d)‏ a = Phi(a2,a)‏ b = Phi(b2,b)‏ c = Phi(c3,c)‏ d = Phi(d2,d)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0 a1 b1 c1 d1 i1 a2 c2 d3 a3 d4

Renaming – Example (After BB5)‏ a2 = c2 = b2 = c3 = d2 = a3 = d3 = c4 =d4 = b = i = a0 = b0 = c0 = i0 = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a1 = Phi(a0,a)‏ b1 = Phi(b0,b)‏ c1 = Phi(c0,c)‏ d1 = Phi(d0,d)‏ i1 = Phi(i0,i)‏ c = Phi(c2,c4)‏ d = Phi(d4,d3)‏ a = Phi(a2,a)‏ b = Phi(b2,b)‏ c = Phi(c3,c)‏ d = Phi(d2,d)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0 a1 b1 c1 d1 i1 a2 c2 d3 a3 c4

Renaming – Example (After BB6)‏ a2 = c2 = b2 = c3 = d2 = a3 = d3 = c4 =d4 = b3 = i = a0 = b0 = c0 = i0 = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a1 = Phi(a0,a)‏ b1 = Phi(b0,b)‏ c1 = Phi(c0,c)‏ d1 = Phi(d0,d)‏ i1 = Phi(i0,i)‏ c5 = Phi(c2,c4)‏ d5 = Phi(d4,d3)‏ a = Phi(a2,a3)‏ b = Phi(b2,b3)‏ c = Phi(c3,c5)‏ d = Phi(d2,d5)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0 a1 b1 c1 d1 i1 a2 b3 c2 d3 a3 c5 d5

Renaming – Example (After BB7)‏ a2 = c2 = b2 = c3 = d2 = a3 = d3 = c4 =d4 = b3 = i2 = a0 = b0 = c0 = i0 = BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 a1 = Phi(a0,a4)‏ b1 = Phi(b0,b4)‏ c1 = Phi(c0,c6)‏ d1 = Phi(d0,d6)‏ i1 = Phi(i0,i2)‏ c5 = Phi(c2,c4)‏ d5 = Phi(d4,d3)‏ a4 = Phi(a2,a3)‏ b4 = Phi(b2,b3)‏ c6 = Phi(c3,c5)‏ d6 = Phi(d2,d5)‏ var: a b c d i ctr: stk: a0 b0 c0 d0 i0 a1 b1 c1 d1 i1 a2 b4 c2 d6 i2 a4 c6 Fin!