The document discusses machine-independent optimizations in compiler design, focusing on data-flow analysis. It outlines key concepts such as available expression computation, control-flow analysis, and the algorithms used for optimizations. The lecture includes definitions, equations, and iterative algorithms for computing available expressions in code optimization.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
43 views9 pages
Available Expression Analysis
The document discusses machine-independent optimizations in compiler design, focusing on data-flow analysis. It outlines key concepts such as available expression computation, control-flow analysis, and the algorithms used for optimizations. The lecture includes definitions, equations, and iterative algorithms for computing available expressions in code optimization.
Illustrations of code optimizations (in part 1) Examples of data-flow analysis Fundamentals of control-flow analysis Algorithms for two machine-independent optimizations SSA form and optimizations
Y.N. Srikant Data-Flow Analysis
Available Expression Computation
Sets of expressions constitute the domain of data-flow
values Forward flow problem Confluence operator is \ An expression x + y is available at a point p, if every path (not necessarily cycle-free) from the initial node to p evaluates x + y , and after the last such evaluation, prior to reaching p, there are no subsequent assignments to x or y A block kills x + y , if it assigns (or may assign) to x or y and does not subsequently recompute x + y . A block generates x + y , if it definitely evaluates x + y , and does not subsequently redefine x or y
Y.N. Srikant Data-Flow Analysis
Available Expression Computation - EGEN and EKILL
Y.N. Srikant Data-Flow Analysis
Available Expression Computation - DF Equations (1)
The data-flow equations
\ IN[B] = OUT [P], B not initial P is a predecessor of B [ OUT [B] = e_gen[B] (IN[B] e_kill[B]) IN[B1] = IN[B] = U, for all B 6= B1 (initialization only )
B1 is the intial or entry block and is special because
nothing is available when the program begins execution IN[B1] is always U is the universal set of all expressions Initializing IN[B] to for all B 6= B1, is restrictive
Y.N. Srikant Data-Flow Analysis
Available Expression Computation - DF Equations (2)
Y.N. Srikant Data-Flow Analysis
Available Expression Computation - An Example
Y.N. Srikant Data-Flow Analysis
Available Expression Computation - An Example (2)
Y.N. Srikant Data-Flow Analysis
An Iterative Algorithm for Computing Available Expressions for each block B 6= B1 do {OUT [B] = U e_kill[B]; } /* You could also do IN[B] = U;*/ /* In such a case, you must also interchange the order of */ /* IN[B] and OUT [B] equations below */ change = true; while change do { change = false; for each block B 6= B1 do { \ IN[B] = OUT [P]; P a predecessor of B oldout = OUT [B]; [ OUT [B] = e_gen[B] (IN[B] e_kill[B]);