lecture-11

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

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

View Full Document Right Arrow Icon
Datafow Analysis Wednesday, November 9, 2011
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
Build CFG x = 1; y = x + 2; if (y > x) then y = 5; ... y . ..
Background image of page 10
Image of page 11
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 Right Arrow Icon
Ask a homework question - tutors are online