Docsity

Control Dependence - Advanced Compiling Techniques - Lecture Slides, Slides of Compilers

Partial preview of the text

Download Control Dependence - Advanced Compiling Techniques - Lecture Slides and more Slides Compilers in PDF only on Docsity!

Control Dependence

Control Dependence

  • Introduction
  • Formal Definition
  • Optimal Control Dependence Computation

Applications of CD

  • Dead code elimination
  • Scheduling (hyper-block formation)
  • Predication
  • …

Simple Dead Code Elimination

  • Mark inherently live statement live
    • Store to memory, print, …
  • For each variable in these live statements,

mark its definition statement live.

  • For each live statement, mark it live the node

that it is control dependent on.

  • Remove everything that is not marked.

Control Dependence

  • Introduction
  • Formal Definition
  • Optimal Control Dependence Computation

Post-dominator Relation

  • If X appears on every path from START to Y, then X dominates Y.
  • If X appears on every path from Y to END, then X postdominates Y.
  • Postdominator Tree
    • END is the root
    • Any node Y other than END has ipdom(Y) as its parent
    • Parent, child, ancestor, descendant

Example

a b c d e S→a b→c

S

a

b

c

d (^) E

CFG

e

E

Pdom Tree

Control Dep Relation

Example

a b c d e S→a b→c

S

a

b

c

d (^) E

CFG

e

E

e

d

S

b

c

Pdom Tree a

Control Dep Relation

Control Dependence Queries

  • CD(e): set of nodes control dependent on edge e
  • CONDS(v): set of edges that node v is control dependent on

Dominance Frontier

  • Reverse control flow graph (RCFG)
  • Let X and Y be nodes in CFG. X in DF(Y) in CFG iff Y is control dependent on X in RCFG.
  • DF(Y) in CFG = conds(Y) in RCFG, where conds(Y) is the set of nodes that Y is control dependent on.

Worst-case Size of CDR

a b c d

S→a √ √ √ √

d→a √ √ √ √

c→b √ √

CFG

Control Dependence Relation Size = O(n 2 )

S

a

b

c

E

d

Control Dependence

  • Introduction
  • Formal Definition
  • Optimal Linear Control Dependence

Computation

Key Idea (I): Exploit Structure

  • How to avoid building the entire control dependence relation (O(n 2 ))? - Nodes that are control dependent on an edge e form a simple path in the postdominator tree - In a tree, a simple path is uniquely specified by its endpoints.
  • Pdom tree + endpoints of each control dependence path can be built in O(|E|) space and time

Example

E path S→a? b→c?

a b c d e S→a √ √ √ b→c √ √ √

S

a

b

c

d (^) E

CFG

e

Pdom Tree

c

E

e

d

S

b a

Control Dep Relation

Path Array