l4-handout

l4-handout - Lecture 4 More on Data Flow: Constant...

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

View Full Document Right Arrow Icon
1 Lecture 4 More on Data Flow: Constant Propagation, Speed, Loops I. Constant Propagation II. Efficiency of Data Flow Analysis III. Algorithm to find loops Reading: Chapter 9.4, 9.6 M. Lam CS243: Constants, Speed, Loops 1 I. Constant Propagation/Folding At every basic block boundary, for each variable v determine if v is a constant if so, what is the value? M. Lam CS243: Constants, Speed, Loops 2 x = 2 m = x + e e = 3 p = e + 4 e = 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Semi-lattice Diagram Finite domain? Finite height? M. Lam CS243: Constants, Speed, Loops 3 Equivalent Definition Meet Operation: Note: undef c2 = c2! M. Lam CS243: Constants, Speed, Loops 4 v1 v2 v1 v2 undef undef c 2 NAC c 1 undef c 2 NAC NAC undef c 2 NAC
Background image of page 2
3 Example M. Lam CS243: Constants, Speed, Loops 5 x = 2 p = x Transfer Function Assume a basic block has only 1 instruction Let IN[b,x], OUT[b,x] be the information for variable x at entry and exit of basic block b OUT[entry, x] = undef, for all x. Non-assignment instructions: OUT[b,x] = IN[b,x] Assignment instructions: (next page) M. Lam CS243: Constants, Speed, Loops 6
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Constant Propagation (Cont.) Let an assignment be of the form x 3 = x 1 + x 2 “+” represents a generic operator OUT[b,x] = IN [b,x], if x x 3 Use: x y implies f(x) f(y) to check if framework is monotone [v 1 v 2 . .. ] [v 1 ’ v 2 ’ . .. ], f([v 1 v 2 . .. ]) f ([v 1 ’ v 2 ... ]) M. Lam CS243: Constants, Speed, Loops 7 IN[b,x 1 ] IN[b,x 2 ] OUT[b,x 3 ] undef undef c 2 NAC c 1 undef c 2 1 2 NAC NAC undef c 2 NAC Distributive? Iterative solutions is not precise!
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

l4-handout - Lecture 4 More on Data Flow: Constant...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online