lecture-11

# lecture-11 - Dataow Analysis Wednesday November 9 2011...

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

Datafow Analysis Wednesday, November 9, 2011

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 Wednesday, November 9, 2011
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? Wednesday, November 9, 2011

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 Wednesday, November 9, 2011
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 . .. Wednesday, November 9, 2011

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 . .. Wednesday, November 9, 2011
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 . .. Wednesday, November 9, 2011

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) Wednesday, November 9, 2011
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 Replace constant-valued variable uses with their values, try to simplify expressions and control Fow Wednesday, November 9, 2011

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

View Full Document
Build CFG x = 1; y = x + 2; if (y > x) then y = 5; ... y . ..
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.

### Page1 / 47

lecture-11 - Dataow Analysis Wednesday November 9 2011...

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

View Full Document
Ask a homework question - tutors are online