Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Algorithm for Computing φ-Functions with DJ Graphs in SSA Form, Assignments of Computer Science

An iterative algorithm proposed by das and ramakrishna for computing φ-functions in the context of static single assignment (ssa) form. The algorithm uses a dominator tree with j-edges (dj graph) and top-down merge set computation. The document also covers related work and provides complexity analysis.

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-49p
koofers-user-49p 🇺🇸

10 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
A Practical and Fast Iterative Algorithm for
φ-Function Computation Using DJ Graphs
Dibyendu Das
U. Ramakrishna
ACM Transactions on Programming Languages and Systems
May 2005
Humayun Zafar
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Algorithm for Computing φ-Functions with DJ Graphs in SSA Form and more Assignments Computer Science in PDF only on Docsity!

A Practical and Fast Iterative Algorithm for^ φ

-Function Computation Using DJ Graphs

Dibyendu Das

U. Ramakrishna

ACM Transactions on Programming Languages and Systems

May 2005

Humayun Zafar

Outline ‡

Introduction to a compiler.

Static Single Assignment.

Related Work.

TDMSC-I

TDMSC-II

Implementation and Experiments.

Conclusion

Static Single-Assignment ‡

Adds information about both control flow anddata flow to the program text.

Encodes information about definitions and usesthem in the name space of the code.

Each distinct name is defined by a singleoperation in the code – hence the name.

How to reconcile this single-assignmentdiscipline with the effects of control flow?

Insert phi (

) functions, at points where the control-

flow paths meet.

A Small Loop in SSA Form x

Å

y

Å

while (x < 100)

x

Å

x + 1

y

Å

y + 1

Original Code

x

Å

y

Å

If (x

>= 100) goto next

loop:

x

Å

(x

, x

y

Å

(y

, y

x

Å

x

y

Å

y

+ x

If (x

< 100) goto loop

next:

x

Å

(x

, x

y

Å

(y

, y

Its SSA Form

Static Single-Assignment ‡

Does not have anobvious constructionalgorithm.

Central to the idea ofSSA is the placement of φ

-functions.

Das and Ramakrishna.

Propose an algorithmwhich computes the

function based on themerge set of each CFG ofeach function.

An Example – CFG and DJ Graph ‡

J-edges.

If

e

s

,^

t ) but

s

does

not

strictly dominate

t

, then

e

is called a J-

edge and

s

is the source and

t

the target nodes.

DJ Graph.

Sreedhar and Gao [1995] define a DJ graph to be a dominator

tree with the J-edges added.

Dominance Frontier.

A node

v

is said to be in

DF

w

), if a predecessor of

v

is

dominated by

w

but

v

is not strictly dominated by

w

Three J edges in the DJ graph.

DF sets in braces.

Top Down Merge Set Computation-I 01: RequireAnotherPass = False; 02: while (in B(readth) F(irst) S(earch) order) do 03: Let n = Next Node in the BFS list 04: for (all incoming edges to n )^ do 05: Let e = Incoming edge 06: if ( e^ is a J-edge && e not visited) then 07: Visit ( e ) 08: Let snode = Source Node of e 09: Let tnode = Target Node of e 10: Let tmp = snode 11: Let lnode = NULL 12: while ( level ( tmp )^ ≥ level ( tnode )) do 13: Merge ( tmp ) = Merge ( tmp ) U Merge ( tnode ) U { tnode } 14: lnode = tmp 15: tmp = parent ( tmp ) // dominator tree parent 16: end while 17: for (all incoming edges to lnode )^ do // lnode ancestor of snode 18: Let e = Incoming edge 19: if ( e is a J-edge && e visited) then 20: Let snode = Source Node of e 21: if ( Merge ( snode )!(Subset) Merge ( lnode )) then // Check inconsistency 22: RequireAnotherPass = True 23: end if 24: end if 25: end for 26: end if 27: end for 28: end while 29: return RequireAnotherPass

Complete Top Down Merge SetComputation 1: do 2: RequireAnotherPass = TDMSC-I( GDJ ) 3: while (RequireAnotherPass)

An Example From 254.gap

First column indicateshow many times themerge algorithm wasinvoked.

The other columns showhow many of thosecompleted in 1, 2 and 3passes respectively.

Complexity of TDMSC-I ‡

Consists of three parts:

BFS.

Merge set computation.

Consistency check.

BFS

Can be done in

O

V

E

Merge set computation

Can be done in

O

h

avg

J

Consistency check

Can be done in

O

e

avg

J

Improvements to the Iterative MergeSet Computation Algorithm 01: RequireAnotherPas s^ = False; 02: while (in BFS order) do 03: Let n = Next Node in the BFS list 04: for (all incoming edges to n )^ do 05: Let e = Incoming edge 06: if^ ( e is a J-edge & &^ e^ not visited) then 07: Visit ( e ) 08: Let snode = Source Node of e 09: Let tnode = Target Node of e 10: Let tmp = snode 11: Let lnode = NULL 12: while ( level ( tmp )^ ≥ level ( tnode ))^ do 13: Merge ( tmp ) = Merge ( tmp ) U Merge ( tnode ) U { tnode } 14: lnode = tmp 15: tmp = parent ( tmp ) // dominator t ree parent 16: end while 17: for (all incoming edges to lnode )^ do 18: Let e = Incoming edge 19: if^ ( e is a J-edge && e visited) then 20: Let snode = Source Node of e 21: if^ ( Merge ( snode ) !(Subset) Merge ( lnode ))^ then 22: Let node = snode 23: Let lnode = NULL 24: while ( level ( node )^ ≥ level ( lnode ))^ do 25: // Local Cor rection for Shadow (( snode ,^ lnode )) 26: Merge ( node ) = Merge ( node ) U Merge ( lnode ) 27: lnode = node 28: node = parent ( node ) 29: end while 30: if^ ( An Incoming J Edge Inconsistent ( lnode ))^ then 31: RequireAnotherPas s^ = True 32: end if 33: end if 34: end if 35: end for 36: end if 37: end for 38: end while 39: return RequireAnotherPass 01: RequireAnotherPass = False; 02: while (in B(readth) F(irst) S(earch) order) do 03: Let n = Next Node in the BFS list 04: for (all incoming edges to n )^ do 05: Let e = Incoming edge 06: if^ ( e is a J-edge && e not visited) then 07: Visit ( e ) 08: Let snode = Source Node of e 09: Let tnode = Target Node of e 10: Let tmp = snode 11: Let lnode = NULL 12: while ( level ( tmp )^ ≥ level ( tnode )) do 13: Merge ( tmp ) = Merge ( tmp ) U Merge ( tnode ) U { tnode } 14: lnode = tmp 15: tmp = parent ( tmp ) // dominator tree parent 16: end while 17: for (all incoming edges to lnode )^ do // lnode ancestor of snode 18: Let e = Incoming edge 19: if^ ( e is a J-edge && e visited) then 20: Let snode = Source Node of e 21: if ( Merge ( snode )!(Subset) Merge ( lnode )) then // Check inconsistency 22: RequireAnotherPass = True 23: end if 24: end if 25: end for 26: end if 27: end for 28: end while 29: return RequireAnotherPass

Improvement?

TDMSC-II

cuts down on

the second pass forSpec2000 benchmarks toaround 5%.

The number of caseswhere a third pass isrequired is just 3.

Complexity

An extra

O

e

avg

h

avg

| J

|) added.

Compile Time Comparisons

Conclusion ‡

Algorithm computes the merge sets of all thebasic blocks statically and uses these sets tofind the

points.

No additional data structure other than the DJgraph has been used for this purpose.