# l5 - Lecture 5 Partial Redundancy Elimination I Forms of...

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

Carnegie Mellon Lecture 5 Partial Redundancy Elimination I. Forms of redundancy global common subexpression elimination loop invariant code motion partial redundancy II. Lazy Code Motion Algorithm Mathematical concept: a cut set Basic technique (anticipation) 3 more passes to refine algorithm Reading: Chapter 9.5 M. Lam CS243: Partial Redundancy Elimination 1

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

View Full Document
Carnegie Mellon Overview Eliminates many forms of redundancy in one fell swoop Originally formulated as 1 bi-directional analysis Lazy code motion algorithm formulated as 4 separate uni-directional passes backward, forward, forward, backward M. Lam CS243: Partial Redundancy Elimination 2
Carnegie Mellon I. Common Subexpression Elimination A common expression may have different values on different paths! On every path reaching p, expression b+c has been computed b, c not overwritten after the expression M. Lam CS243: Partial Redundancy Elimination 3 Build up intuition about redundancy elimination with examples of familiar concepts d = b + c a = b + c b = 7 d = b + c a = b + c b = 7 f = b + c d = b + c a = b + c

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

View Full Document
Carnegie Mellon Loop Invariant Code Motion Given an expression (b+c) inside a loop, does the value of b+c change inside the loop? is the code executed at least once? M. Lam CS243: Partial Redundancy Elimination 4 a = t t = b + c a = b + c a = b + c b = read() a = b + c exit
Carnegie Mellon Partial Redundancy Can we place calculations of b+c such that no path re-executes the same expression Partial Redundancy Elimination (PRE) subsumes: global common subexpression (full redundancy) loop invariant code motion (partial redundancy for loops) M. Lam CS243: Partial Redundancy Elimination 5 Unifying theory: More powerful, elegant but less direct. d = b + c a = b + c

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

View Full Document
Carnegie Mellon II. Preparing the Flow Graph Key observation Can replace a bi-directional (!) data flow with several unidirectional data flows much easier Better result as well! Definition: Critical edges source basic block has multiple successors destination basic block has multiple predecessors Modify the flow graph: (treat every statement as a basic block) To keep algorithm simple: restrict placement of instructions to the
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 21

l5 - Lecture 5 Partial Redundancy Elimination I Forms of...

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

View Full Document
Ask a homework question - tutors are online