120 likes | 257 Views
Review for the Course. Iterative Dataflow Analysis. Reaching definitions Live variables. Iterative Dataflow Analysis. Foundations of Data Flow Analysis . Correctness Equations will be satisfied when the program terminates. Is this the solution that we want?
E N D
Iterative Dataflow Analysis • Reaching definitions • Live variables
Foundations of Data Flow Analysis • Correctness • Equations will be satisfied when the program terminates. Is this the solution that we want? • Precision: how good is the answer? • Is the answer ONLY a union of all possible execution paths? • Convergence: will the answer terminate? • Or, will there always be some nodes that change? • Speed: how fast is the convergence? • how many times will we visit each node?
Solving Data Flow Problems • Semi-Lattice • Set of values, meet operator, top & bottom, finite descending chain • Transfer Functions • function of each basic block, monotone, distributive • FP ≤ MFP ≤ MOP ≤ Perfect-Solution • Algorithm • initialization step (entry/exit) • visit order: rPostOrder • depth of the graph
Global CSE: Available Expressions • Domain: A bit vector, a bit for each lexically unique expression in the program • Forward or Backward problem? • Meet operator? • check commutative, idempotent, associative • Partial ordering • Lattice elements? • Top? Bottom? • Initialization for iterative algorithm
Finding Natural loops • Find the dominator relations in a flow graph • Identify the back edges • Find the natural loop associated with the back edge
Loop Invariant Code Motion • Finding loop-invariant computations • Check conditions for code motion
Strength Reduction and Induction Variable Elimination • Strength Reduction Let A be an induction variable in a family of basic induction variable B (i.e., A = c1 × B + c2) • Create a new variable: A’ • Initialization in preheader: A’ = c1 × B + c2 • Track value of B: add after B = B + x: A’ = A’ + x × c1 • Replace assignment to A: A = A’ • Work also for non-trivial BIVs
Register Allocation Modeled by coloring interference graph Spilling • A node whose degree < n can always be colored • Optimistic coloring Live range splitting Rematerialization Coalescing
Instruction Scheduling Techniques Instruction scheduling is constrained by resource and dependenceconstraints Categories of instruction scheduling • Local, basic block scheduling List scheduling • Global, cross-block scheduling Speculation, join motion, unification, renaming, substitution • Software pipelining Modulo scheduling, enhanced pipeline scheduling