# l4 - Lecture 4 More on Data Flow Constant Propagation Speed...

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

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

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

View Full Document
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
Semi-lattice Diagram Finite domain? Finite height? M. Lam CS243: Constants, Speed, Loops 3

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

View Full Document
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
Example M. Lam CS243: Constants, Speed, Loops 5 x = 2 p = x

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

View Full Document
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
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

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

View Full Document
Distributive? Iterative solutions is not precise!
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 23

l4 - Lecture 4 More on Data Flow Constant Propagation Speed...

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

View Full Document
Ask a homework question - tutors are online