Partial Redundancy Elimination: Techniques for Efficient Expression Evaluation, Slides of Compilers

Partial redundancy elimination (pre), a technique used to optimize expression evaluation in computer programs. Pre includes methods like loop-invariant code motion, common subexpression elimination, and true partial redundancy elimination. The document also covers node splitting and the importance of determining the earliest and latest placement of expressions to minimize redundancy.

Typology: Slides

2012/2013

Uploaded on 04/29/2013

aalok
aalok 🇮🇳

4.4

(15)

97 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Partial Redundancy Elimination
Finding the Right Place to Evaluate
Expressions
Four Necessary Data-Flow Problems
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Partial Redundancy Elimination: Techniques for Efficient Expression Evaluation and more Slides Compilers in PDF only on Docsity!

Partial Redundancy Elimination

Finding the Right Place to Evaluate Expressions Four Necessary Data-Flow Problems

Role of PRE

  • Generalizes:
    1. Moving loop-invariant computations outside the loop.
    2. Eliminating common subexpressions.
    3. True partial redundancy: an expression is sometimes available, sometimes not.

Example: Loop-Invariant Code

Motion

4

t = x+y

= x+y (^) = t

Example: Common Subexpression

Elimination

5

= x+y = x+y

= x+y

t = x+y t = x+y

= t

Modifying the Flow Graph

  1. Add a new block along an edge.
    • Only necessary if the edge enters a block with several predecessors.
  2. Duplicate blocks so an expression x+y is evaluated only along paths where it is needed.

Example: Node Splitting

8

t = x+y

= t

= x+y

= x+y

= x+y

t = x+y

Da Plan Boss --- Da Plan

  1. Determine for each expression the earliest place(s) it can be computed while still being sure that it will be used.
  2. Postpone the expressions as long as possible without introducing redundancy.
  • We trade space for time --- an expression can be computed in many places, but never if it is already computed.

The Guarantee

  • No expression is computed at a place where it its value might have been computed previously, and preserved instead. - Even along a subset of the possible paths.

Anticipated Expressions

  • Expression x+y is anticipated at a point if x+y is certain to be evaluated along any computation path, before any recomputation of x or y.
  • An example of the fourth kind of DF schema: backwards-intersection.

Example: Anticipated Expressions

14

= x+y = x+y

x+y is anticipatedhere and could be = x+y

computed now rather than later.

= x+y

x+y is anticipated here, but is also available. No computa- tion is needed.

Computing Anticipated Expressions

  • Direction = backwards.
  • Meet = intersection.
  • Boundary condition: IN[exit] = ∅.
  • Transfer function: IN[B] = (OUT[B] – Def(B)) ∪ Use(B)

Example: Anticipated Expressions

17

= x+y

= x+y

Anticipated

Backwards; Intersection; IN[B] = (OUT[B] – Def(B)) ∪ Use(B)Docsity.com

“Available” Expressions

  • x+y is in Kill(B) if x or y is defined, and x+y is not later recomputed (same as previously).
  • Confluence = intersection.
  • Transfer function:

OUT[B] = (IN[B] ∪ INANTICIPATED[B]) – Kill(B)

Earliest Placement

  • x+y is in Earliest[B] if it is anticipated at the beginning of B but not “available” there. - That is: when we compute anticipated expressions, x+y is in IN[B], but - When we compute “available” expressions, x+y is not in IN[B].
  • I.e., x+y is anticipated at B, but not anticipated at OUT of some predecessor.