Dataflow Analysis Topic today Data flow analysis: Section 3 of Representation and Analysis Paper (Section 3) NOTE we finished through slide 30 on Friday.

Slides:



Advertisements
Similar presentations
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
Advertisements

School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) SSA Guo, Yao.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
Lecture 11: Code Optimization CS 540 George Mason University.
Chapter 9 Code optimization Section 0 overview 1.Position of code optimizer 2.Purpose of code optimizer to get better efficiency –Run faster –Take less.
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
CS412/413 Introduction to Compilers Radu Rugina Lecture 37: DU Chains and SSA Form 29 Apr 02.
Some Properties of SSA Mooly Sagiv. Outline Why is it called Static Single Assignment form What does it buy us? How much does it cost us? Open questions.
1 Introduction to Data Flow Analysis. 2 Data Flow Analysis Construct representations for the structure of flow-of-data of programs based on the structure.
Jeffrey D. Ullman Stanford University. 2  Generalizes: 1.Moving loop-invariant computations outside the loop. 2.Eliminating common subexpressions. 3.True.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Dataflow Analysis Introduction Guo, Yao Part of the slides are adapted from.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Partial Redundancy Elimination Guo, Yao.
1 Data flow analysis Goal : collect information about how a procedure manipulates its data This information is used in various optimizations For example,
Foundations of Data-Flow Analysis. Basic Questions Under what circumstances is the iterative algorithm used in the data-flow analysis correct? How precise.
1 CS 201 Compiler Construction Lecture 5 Code Optimizations: Copy Propagation & Elimination.
More Dataflow Analysis CS153: Compilers Greg Morrisett.
1 Data flow analysis Goal : –collect information about how a procedure manipulates its data This information is used in various optimizations –For example,
CS 536 Spring Global Optimizations Lecture 23.
Global optimization. Data flow analysis To generate better code, need to examine definitions and uses of variables beyond basic blocks. With use- definition.
Data Flow Analysis Compiler Design Nov. 3, 2005.
From last time: reaching definitions For each use of a variable, determine what assignments could have set the value being read from the variable Information.
4/25/08Prof. Hilfinger CS164 Lecture 371 Global Optimization Lecture 37 (From notes by R. Bodik & G. Necula)
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Data Flow Analysis Compiler Design October 5, 2004 These slides live on the Web. I obtained them from Jeff Foster and he said that he obtained.
CS 412/413 Spring 2007Introduction to Compilers1 Lecture 29: Control Flow Analysis 9 Apr 07 CS412/413 Introduction to Compilers Tim Teitelbaum.
U NIVERSITY OF M ASSACHUSETTS, A MHERST D EPARTMENT OF C OMPUTER S CIENCE Advanced Compilers CMPSCI 710 Spring 2003 Data flow analysis Emery Berger University.
2015/6/29\course\cpeg421-08s\Topic4-a.ppt1 Topic-I-C Dataflow Analysis.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Loops Guo, Yao.
Machine-Independent Optimizations Ⅰ CS308 Compiler Theory1.
From last time: reaching definitions For each use of a variable, determine what assignments could have set the value being read from the variable Information.
Global optimization. Data flow analysis To generate better code, need to examine definitions and uses of variables beyond basic blocks. With use- definition.
Ben Livshits Based in part of Stanford class slides from
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
1 CS 201 Compiler Construction Data Flow Analysis.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
1 Data-Flow Analysis Proving Little Theorems Data-Flow Equations Major Examples.
Data Flow Analysis. 2 Source code parsed to produce AST AST transformed to CFG Data flow analysis operates on control flow graph (and other intermediate.
Data Flow Analysis Compiler Baojian Hua
1 Code Optimization Chapter 9 (1 st ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University,
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
MIT Introduction to Program Analysis and Optimization Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
Jeffrey D. Ullman Stanford University. 2 boolean x = true; while (x) {... // no change to x }  Doesn’t terminate.  Proof: only assignment to x is at.
1 Data Flow Analysis Data flow analysis is used to collect information about the flow of data values across basic blocks. Dominator analysis collected.
Generating SSA Form (mostly from Morgan). Why is SSA form useful? For many dataflow problems, SSA form enables sparse dataflow analysis that –yields the.
1 Control Flow Analysis Topic today Representation and Analysis Paper (Sections 1, 2) For next class: Read Representation and Analysis Paper (Section 3)
Final Code Generation and Code Optimization.
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
1 Control Flow Graphs. 2 Optimizations Code transformations to improve program –Mainly: improve execution time –Also: reduce program size Can be done.
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
CS 598 Scripting Languages Design and Implementation 9. Constant propagation and Type Inference.
Data Flow Analysis II AModel Checking and Abstract Interpretation Feb. 2, 2011.
1 Code Optimization Chapter 9 (1 st ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University,
Optimization Simone Campanoni
Code Optimization Data Flow Analysis. Data Flow Analysis (DFA)  General framework  Can be used for various optimization goals  Some terms  Basic block.
COMPILERS Liveness Analysis hussein suleman uct csc3003s 2009.
Data Flow Analysis Suman Jana
Simone Campanoni DFA foundations Simone Campanoni
Dataflow Testing G. Rothermel.
Topic 10: Dataflow Analysis
University Of Virginia
1. Reaching Definitions Definition d of variable v: a statement d that assigns a value to v. Use of variable v: reference to value of v in an expression.
Data Flow Analysis Compiler Design
Topic-4a Dataflow Analysis 2019/2/22 \course\cpeg421-08s\Topic4-a.ppt.
Final Code Generation and Code Optimization
Static Single Assignment
Live variables and copy propagation
COMPILERS Liveness Analysis
Presentation transcript:

Dataflow Analysis Topic today Data flow analysis: Section 3 of Representation and Analysis Paper (Section 3) NOTE we finished through slide 30 on Friday 9/10, will continue from there on Monday 9/14 For Wednesday 9/16: Read Representation and Analysis Paper (Sections 4, 5) Do problems 3 and 4 from Section 10 of the paper, starting from CFGs posted in answer to problems 1 and 2

Data-flow Analysis 1.Introduction (motivation, overview) 2.Data-flow problems 3.Iterative data-flow analysis  Reaching definitions  Reachable uses 4.Worklist data-flow analysis 5.Additional issues

Data-flow Analysis 1.Introduction (motivation, overview) 2.Data-flow problems 3.Iterative data-flow analysis  Reaching definitions  Reachable uses 4.Worklist data-flow analysis 5.Additional issues

Compiler optimization  common subexpression elimination need  need to know available expressions: which expressions have been computed at the point before this statement to know available expressions: which expressions have....been computed at the point before this statement Introduction (Uses of Data-flow) c=a+bd=a+b e=a+b... t=a+b c=t t=a+b d=t e=t...

Introduction (Uses of Data-flow) Compiler optimization  constant propagation o suppose every assignment to c that reaches this statement assigns 5 o then a can be replaced by 15 o need to know reaching definitions: which definitions of variable c reach this statement a=c+10

Introduction (Uses of Data-flow) Software engineering tasks  Data-flow testing o suppose that a statement assigns a value but the use of that value is never executed under test o need definition-use pairs (du-pairs): associations between definitions and uses of the same variable or memory location a=c+10 d=a+y a is not used on this path

Introduction (Uses of Data-flow) Software engineering tasks  Debugging o suppose that a has an incorrect value in the statement o need data dependence information: statements that can affect the incorrect value at this point a=c+y

Introduction (Overview) Data-flow analysis provides information for these and other tasks by computing the flow of different types of data to points in the program Representations used o Structured programs: data-flow analysis can be performed on an abstract-syntax tree (AST) o General programs: data-flow analysis performed on the control-flow graph (CFG)

Introduction (Overview)  Exact solutions to most data-flow problems are undecidable o May depend on input o May depend on outcome of a conditional statement o May depend on termination of loop Thus, we compute approximations to the exact solution

Introduction (Overview) Approximate analysis can overestimate the solution o Solution contains actual information plus some spurious information but does not omit any actual information o This type of information is safe or conservative but may be very imprecise Approximate analysis can underestimate the solution o Solution may not contains all information in the actual solution o This type of information in unsafe For optimization, what do we need? For software engineering tasks, what do we need?

Introduction (Overview) Biggest challenge for data-flow analysis: provide sufficiently accurate information, efficiently

Data-flow Analysis 1.Introduction (motivation, overview) 2.Data-flow problems 3.Iterative data-flow analysis  Reaching definitions  Reachable uses 4.Worklist data-flow analysis 5.Additional issues

Compute the flow of data to points in the program --- e.g.,  Where does the assignment to I in statement 1 reach?  Where does the expression computed in statement 2 reach?  Which uses of variable J are reachable from the end of B1?  Is the value of variable I live after statement 3? Interesting points before and after basic blocks or statements 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4 Data-flow Problems

Data-flow Problems (Reaching Definitions) A definition of a variable or memory location is a point or statement where that variable gets a value --- e.g., input statement, assignment statement. A definition of A reaches a point p if there exists a control-flow path in the CFG from the definition to p with no other definitions of A on the path (called a definition-clear path) Such a path may exist in the graph but may not be executable (i.e., there may be no input to the program that will cause it to be executed); such a path is infeasible. 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4

Data-flow Problems (Reaching Definitions) Where are the definitions in the program (in which statements)? o Of variable I: o Of variable J: Which basic blocks (before the block) do these definitions reach? o Def 1 reaches o Def 2 reaches o Def 3 reaches o Def 4 reaches o Def 5 reaches 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4

Data-flow Problems (Reaching Definitions) Where are the definitions in the program (in which statements)? o Of variable I: 1, 3 o Of variable J: 2, 4, 5 Which basic blocks (before the block) do these definitions reach? o Def 1 reaches B2 o Def 2 reaches B1, B2, B3 o Def 3 reaches B1, B3, B4 o Def 4 reaches B4 o Def 5 reaches exit 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4

Data-flow Analysis 1.Introduction (motivation, overview) 2.Data-flow problems 3.Iterative data-flow analysis  Reaching definitions  Reachable uses 4.Worklist data-flow analysis 5.Additional issues

Iterative Data-flow Analysis (Reaching Definitions) 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4

Iterative Data-flow Analysis (Reaching Definitions) Method: 1.Compute two kinds of local information (i.e., within a basic block) o GEN[B] is the set of definitions that are created (generated) within B o KILL[B] is the set of definitions that, if they reach the point before B (i.e., the beginning of B) won’t reach the end of B 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4

Iterative Data-flow Analysis (Reaching Definitions) Method (cont’d): 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4

Iterative Data-flow Analysis (Reaching Definitions) Method (cont’d) 2.Compute two other sets by propagation o IN[B] is the set of definitions that reach the beginning of B o OUT[B] is the set of definitions that reach the end of B 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4

Method (cont’d): 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reaching Definitions)

Method (cont’d): 3.Propagation method: o Initialize the IN[B], OUT[B] sets for all B o Iterate over all B until there are no changes to the IN[B], OUT[B] sets o On each iteration, visit all B, and compute IN[B], OUT[B] as IN[B] = union OUT[P], for each P that is a predecessor of B OUT[B] = GEN[B] union (IN[B] – Kill[B]) 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reaching Definitions)

algorithm ReachingDefinitions Input: CFG w/GEN[B], KILL[B] for all B Output: IN[B], OUT[B] for all B begin ReachingDefinitions IN[B]=empty; OUT[B]=GEN[B], for all B; change = true while change do begin Change = false foreach B do begin In[B] = union OUT[P], for each P that is a predecessor of B Oldout = OUT[B] OUT[B] = GEN[B] union (IN[B] – Kill[B]) if OUT[B] != Oldout then change = true endfor endwhile end Reaching Definitions Iterative Data-flow Analysis (Reaching Definitions)

Data-flow for example (set approach) All entries are sets; sets in red indicate changes from last iteration thus, requiring another iteration of the algorithm Init GEN Init KILL Init IN Init OUT Iter1 IN Iter1 OUT Iter2 IN Iter2 OUT I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reaching Definitions)

Data-flow for example (set approach) Init GEN Init KILL Init IN Init OUT Iter1 IN Iter1 OUT Iter2 IN Iter2 OUT 11,21,2,3 4,5 --1,23 2,31,2 231,3--31,22,31,22,3 342,4,5--433,42,33,4 452,4,5--543,53,43,5 1. I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reaching Definitions)

Data-flow for example (bit-vector approach) Init GEN Init KILL Init IN Init OUT Iter1 IN Iter1 OUT I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reaching Definitions)

Data-flow for example (bit-vector approach) Init GEN Init KILL Init IN Init OUT Iter1 IN Iter1 OUT I := 2 2. J := I I := 1 4. J := J J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reaching Definitions)

Questions about algorithm: 1.Is the algorithm guaranteed to converge? Why or why not? 2.What is the worst-case time complexity of the algorithm? 3.What is the worst-case space complexity of the algorithm? 4.Can we order the nodes for visiting to improve the running time of the algorithm? If so how? Iterative Data-flow Analysis (Reaching Definitions)

Data-flow Analysis 1.Introduction (motivation, overview) 2.Data-flow problems 3.Iterative data-flow analysis  Reaching definitions  Reachable uses 4.Worklist data-flow analysis 5.Additional issues

A use of a variable or memory location is a point or statement where that variable is referenced but not changed --- e.g., used in a computation, used in a conditional, output A use of A is reachable from a point p if there exists a control-flow path in the CFG from p to the use with no definitions of A on the path Reachable uses also called upwards exposed uses 1. I := 2 2. J := I I := 1 4. J := 1 + J 5. J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reachable Uses)

Where are the uses in the program (which statements)? o Of variable I: 2.1 o Of variable J: 4.2, 5.1 From which basic blocks (at the ends of blocks) are these uses reachable? Use 2.1 is reachable from entry Use 5.1 is reachable from B4 Use 4.2 is reachable from B1, B2, B3 1. I := 2 2. J := I I := 1 4. J := 1 + J 5. J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reachable Uses)

Where are the uses in the program (which statements)? o Of variable I: 2 o Of variable J: 4, 5 From which basic blocks (at the ends of blocks) are these uses reachable? o Use 2 is reachable from entry o Use 4 is reachable from B1, B2, B3 o Use 5 is reachable from B4 1. I := 2 2. J := I I := 1 4. J := 1 + J 5. J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reachable Uses)

Method: 1.Compute two kinds of local information (i.e., within a basic block) 1. I := 2 2. J := I I := 1 4. J := 1 + J 5. J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reachable Uses)

Method: 1.Compute two kinds of local information (i.e., within a basic block) o GEN[B] is the set of uses that are created (generated) within B and can be reached from the beginning of B (called upwards exposed uses); sometimes called USE[B] o KILL[B] is the set of uses that, if they can be reached from the end of B, cannot be reached from the beginning of B; sometimes called DEF[B] 1. I := 2 2. J := I I := 1 4. J := 1 + J 5. J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reachable Uses)

Method (cont’d): 2.Compute two other sets by propagation 1. I := 2 2. J := I I := 1 4. J := 1 + J 5. J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reachable Uses)

Method: 2.Compute two other sets by propagation o IN[B] is the set of uses that can be reached from the end of B o OUT[B] is the set of uses that can be reached from the beginning of B 1. I := 2 2. J := I I := 1 4. J := 1 + J 5. J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reachable Uses)

Method (cont’d): 3.Propagation method: o Initialize the IN[B], OUT[B] sets for all B o Iterate over all B until there are no changes to the IN[B], OUT[B] sets o On each iteration, visit all B, and compute IN[B], OUT[B] as IN[B] = union OUT[S], S is a successor of B OUT[B] = GEN[B] union (IN[B] – Kill[B]) 1. I := 2 2. J := I I := 1 4. J := 1 + J 5. J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reachable Uses)

Method (cont’d): 3.Propagation method: o Initialize the IN[B], OUT[B] sets for all B o Iterate over all B until there are no changes to the IN[B], OUT[B] sets o On each iteration, visit all B, and compute IN[B], OUT[B] as IN[B] = union OUT[S], for each S that is a successor of B OUT[B] = GEN[B] union (IN[B] – Kill[B]) 1. I := 2 2. J := I I := 1 4. J := 1 + J 5. J := J - 4 B1 B2 B3 B4 Iterative Data-flow Analysis (Reachable Uses)

Questions about algorithm: 1.Is the algorithm guaranteed to converge? Why or why not? 2.What is the worst-case time complexity of the algorithm? 3.What is the worst-case space complexity of the algorithm? 4.Can we order the nodes for visiting to improve the running time of the algorithm? If so how? Iterative Data-flow Analysis (Reachable Uses)

Similarities between RD and RU  Local information (GEN and KILL) computed for each B  IN and OUT sets defined: IN at point where data flows into B from outside B; OUT at point where data flows out of B  Flow into block computed as union of predecessors in flow  Iteration until no more changes Differences between RD and RU  RD flow is forward; RU flow is backward  RD best ordering is topological; RU best ordering is reverse depth-first (reverse topological) Iterative Data-flow Analysis (Reachable Uses)

Data-flow Analysis 1.Introduction (motivation, overview) 2.Data-flow problems 3.Iterative data-flow analysis  Reaching definitions  Reachable uses 4.Worklist data-flow analysis 5.Additional issues

1.Data-flow for nodes 1, 2, 3 never changes but is computed on every iteration of the algorithm 1 return f2 i=2 i<=m return m fib(m) f0=0 m<=1 f1=1 i=i+1 f1=f2 f0=f1 f2=f0+f1 T TF F Worklist Data-flow Analysis

2.Defs involved in the computation may be a small subset of the defs in the graph; for example, what if we only want to compute reaching definitions for f1 1 return f2 i=2 i<=m return m fib(m) f0=0 m<=1 f1=1 i=i+1 f1=f2 f0=f1 f2=f0+f1 T TF F Worklist Data-flow Analysis

algorithm RDWorklist Input: GEN[B], KILL[B] for all B output reaching definitions for each B Method: initialize IN[B], OUT[B] for all B; add successors of B initially involved in computation to worklist W repeat remove B from W Oldout=OUT[B] compute IN[B], OUT[B] if oldout != OUT[B] then add successors of B to W endif until W is empty

Compute RD for f1 using RDWorklist GEN[3] is {3}, GEN[10] is {10}, KILL[3] is {10}, KILL[10] is {3} Add successors of 3, 10 to W 1 return f2 i=2 i<=m return m fib(m) f0=0 m<=1 f1=1 i=i+1 f1=f2 f0=f1 f2=f0+f1 T TF F Worklist Data-flow Analysis remove 4 from W, compute IN[4], OUT[4], etc.

Data-flow Analysis 1.Introduction (motivation, overview) 2.Data-flow problems 3.Iterative data-flow analysis  Reaching definitions  Reachable uses 4.Worklist data-flow analysis 5.Additional issues

DU-Chains, UD-Chains A definition-use chain or DU-chain for a definition D of variable v connects D to all uses of v that it can reach A use-definition chain or UD-chain for a use U of variable v connects U to all definitions of v that reach it

DU-Chains, UD-Chains DU-chain(X,2) DU-chain(X,4) DU-chain(X,5) DU-chain(Y,3) DU-chain(Z,5) DU-chain(Z,6) entry Z > 1 X = 1 Z > 2 Y = X + 1 X = 2 Z = X – 3 X = 4 Z = X + 7 exit B1 B3 B2 B6 B5 B4

DU-Chains, UD-Chains DU-chain(X,2) {(X,3), (X,5)} DU-chain(X,4) {(X,5)} DU-chain(X,5) {(X,6)} DU-chain(Y,3) {} DU-chain(Z,5) {} DU-chain(Z,6) {} entry Z > 1 X = 1 Z > 2 Y = X + 1 X = 2 Z = X – 3 X = 4 Z = X + 7 exit B1 B3 B2 B6 B5 B4

DU-Chains, UD-Chains UD-chain(Z,1) UD-chain(Z,2) UD-chain(X,3) UD-chain(X,5) UD-chain(X,6) entry Z > 1 X = 1 Z > 2 Y = X + 1 X = 2 Z = X – 3 X = 4 Z = X + 7 exit B1 B3 B2 B6 B5 B4

DU-Chains, UD-Chains UD-chain(Z,1) {} UD-chain(Z,2) {} UD-chain(X,3) {(X,2)} UD-chain(X,5) {(X,4)} UD-chain(X,6) {(X,5)} entry Z > 1 X = 1 Z > 2 Y = X + 1 X = 2 Z = X – 3 X = 4 Z = X + 7 exit B1 B3 B2 B6 B5 B4

Data-dependence Graph A data-dependence graph has one node for every variable (basic block) and one edge representing the flow of data between the two nodes Different types of data dependence  Flow: def to use  Anti: use to def  Out: def to def entry Z > 1 X = 1 Z > 2 Y = X + 1 X = 2 Z = X – 3 X = 4 Z = X + 7 exit B1 B3 B2 B6 B5 B4

Data-dependence Graph entry Z > 1 X = 1 Z > 2 Y = X + 1 X = 2 Z = X – 3 X = 4 Z = X + 7 exit B1 B3 B2 B6 B5 B4 entry Z > 1 X = 1 Z > 2 Y = X + 1 X = 2 Z = X – 3 X = 4 Z = X + 7 exit B1 B3 B2 B6 B5 B4

Data-dependence Graph entry Z > 1 X = 1 Z > 2 Y = X + 1 X = 2 Z = X – 3 X = 4 Z = X + 7 exit B1 B3 B2 B6 B5 B4 entry Z > 1 X = 1 Z > 2 Y = X + 1 X = 2 Z = X – 3 X = 4 Z = X + 7 exit B1 B3 B2 B6 B5 B4

Other Data-flow Problems  Live variables  Available expressions

Live Variables A variable v is live at a point P if there is a path in the CFG from P to a use of v on which v is not redefined  Members of the sets  Local information  Propagated sets  Direction of flow  Confluence operator  Transfer functions  Algorithm

Available Expressions An expression is available at a point P if on every path in CFG to P the expression is computed and there is no redefinition of the variables in the expression between the computation and P  Members of the sets  Local information  Propagated sets  Direction of flow  Confluence operator  Transfer functions  Algorithm