# lecture-10 - Dataow Analysis Monday, November 15, 2010...

This preview shows pages 1–10. Sign up to view the full content.

Datafow Analysis Monday, November 15, 2010

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

View Full Document
Program optimizations So far we have talked about different kinds of optimizations Peephole optimizations Local common sub-expression elimination Loop optimizations What about global optimizations Optimizations across multiple basic blocks (usually a whole procedure) Not just a single loop Monday, November 15, 2010
Useful optimizations Common subexpression elimination (global) Need to know which expressions are available at a point Dead code elimination Need to know if the effects of a piece of code are never needed, or if code cannot be reached Constant folding Need to know if variable has a constant value Loop invariant code motion Need to know where and when variables are live So how do we get this information? Monday, November 15, 2010

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

View Full Document
Datafow analysis Framework ±or doing compiler analyses to drive optimization Works across basic blocks Examples Constant propagation: determine which variables are constant Liveness analysis: determine which variables are live Available expressions: determine which expressions are have valid computed values Reaching de²nitions: determine which de²nitions could “reach” a use Monday, November 15, 2010
Example: constant propagation Goal: determine when variables take on constant values Why? Can enable many optimizations Constant folding Create dead code x = 1; y = x + 2; if (x > z) then y = 5 ... y . .. x = 1; y = x + 2; if (y > x) then y = 5 ... y . .. Monday, November 15, 2010

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

View Full Document
Example: constant propagation Goal: determine when variables take on constant values Why? Can enable many optimizations Constant folding Create dead code x = 1; y = x + 2; if (x > z) then y = 5 ... y . .. x = 1; y = 3; if (x > z) then y = 5 ... y . .. x = 1; y = x + 2; if (y > x) then y = 5 ... y . .. Monday, November 15, 2010
Example: constant propagation Goal: determine when variables take on constant values Why? Can enable many optimizations Constant folding Create dead code x = 1; y = x + 2; if (x > z) then y = 5 ... y . .. x = 1; y = 3; if (x > z) then y = 5 ... y . .. x = 1; y = x + 2; if (y > x) then y = 5 ... y . .. x = 1; y = 3; //dead code if (true) then y = 5 //simplify! ... y . .. Monday, November 15, 2010

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

View Full Document
How can we fnd constants? Ideal: run program and see which variables are constant Problem: variables can be constant with some inputs, not others – need an approach that works For all inputs! Problem: program can run Forever (infnite loops?) – need an approach that we know will fnish Idea: run program symbolically Essentially, keep track oF whether a variable is constant or not constant (but nothing else) Monday, November 15, 2010
Overview of algorithm Build control Fow graph We’ll use statement-level C±G (with merge nodes) for this Perform symbolic evaluation Keep track of whether variables are constant or not

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/19/2012 for the course ECE 468 taught by Professor Test during the Fall '08 term at Purdue University-West Lafayette.

### Page1 / 47

lecture-10 - Dataow Analysis Monday, November 15, 2010...

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

View Full Document
Ask a homework question - tutors are online