Notes on Finish Basic Dataflow Analysis Predicate Relation Analysis | EECS 583, Study notes of Electrical and Electronics Engineering

Material Type: Notes; Professor: Mahlke; Class: Advanced Compilers; Subject: Electrical Engineering And Computer Science; University: University of Michigan - Ann Arbor; Term: Winter 2005;

Typology: Study notes

Pre 2010

Uploaded on 09/02/2009

koofers-user-pgf-3
koofers-user-pgf-3 🇺🇸

9 documents

1 / 29

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EECS 583 – Class 8
Finish Basic Dataflow Analysis
Predicate Relation Analysis
University of Michigan
February 2, 2005
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Partial preview of the text

Download Notes on Finish Basic Dataflow Analysis Predicate Relation Analysis | EECS 583 and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

  • 1 -

Reading Material^ Y^ Today’s class^ »^ “Analysis Techniques for Predicated Code”,^ R. Johnson and M. Schlansker, MICRO-29, 1996^ Y^ Material for the next lecture^ »^ Compilers: Principles, Techniques, and Tools

A. Aho, R. Sethi, and J. Ullman, Addison-Wesley, 1988, 9.9, 10.2, 10.3, 10.

  • 3 -

Reaching vs Available Definitions^ 1:r1 = r2 + r3^ 2:r6 = r4 – r

1,2 reach^ 1,2 available^ 3:r4 = 4^ 4:r6 = 8 5:r6 = r2 + r36:r7 = r4 – r5^ 1,2,3,4 reach1 available 1,2 reach 1,2 available

1,3,4 reach 1,3,4 available

  • 4 -

Available Definition Analysis (Adefs)^ Y^ A definition d is available

at a point p if along all

paths

from d to p, d is not killed Y Remember, a definition of a variable is killed

between 2

points when there is another definition of that variablealong the path^ »^ r1 = r2 + r3 kills previous definitions of r1 Y Algorithm^ »^ Forward dataflow analysis as propagation occurs from defsdownwards^ »^ Use the Intersect function as the meet operator to guarantee theall-path requirement^ »^ GEN/KILL/IN/OUT similar to reaching defs^ y^ Initialization of IN/OUT is the tricky part

  • 6 -

Compute IN/OUT Sets for all BBs (Adefs)

U = universal set of all operations in the Procedure IN(0) = 0 OUT(0) = GEN(0) for each basic block in procedure, W, (W != 0), do^ IN(W) = 0^ OUT(W) = U – KILL(W) change = 1 while^ (change) do^ change = 0^ for^ each basic block in procedure, X, do^ old_OUT = OUT(X)^ IN(X) = Intersect(OUT(Y)) for all predecessors Y of X^ OUT(X) = GEN(X) + (IN(X) – KILL(X))^ if^ (old_OUT != OUT(X)) then^ change = 1^ endif^ endfor endfor

  • 7 -

Example Adefs Calculation^ 1: r1 = MEM[r2+0]^ 2: r2 = r2 + 1^ 3: r3 = r1 * r4^ 4: r1 = r1 + 5^ 5: r3 = r5 – r1^ 6: r8 = r3 * 2

7: r7 = 0 8: r1 = r1 + 5 9: r7 = r1 - 6 10: r8 = r7 + r8 11: r1 = r3 – r8 12: r3 = r1 * 2

  • 9 -

Class Problem - Aexprs Calculation^ 1: r1 = r6 * r9^ 2: r2 = r2 + 1^ 3: r5 = r3 * r4^ 4: r1 = r2 + 1^ 5: r3 = r3 * r4^ 6: r8 = r3 * 2

7: r7 = r3 * r4 8: r1 = r1 + 5 9: r7 = r1 - 6 10: r8 = r2 + 1 11: r1 = r3 * r4 12: r3 = r6 * r

  • 10 -

Efficient Calculation of Dataflow^ Y^ Order basic blocks are visited is important (fasterconvergence)^ Y^ Forward analysis – DFS order^ »^ Visit a node only when all its predecessors have been visited^ »^ Visit(n)^ y^

mark n as visited y for each successor of n not yet visited, s, do^ X^ Visit (s) y postorder(n) = count y count += 1 » count = 1; Visit(entry) Y Backward analysis – PostDFS order » Visit a node only when all of its successors have been visited

  • 12 -

Two Types of Analysis^ Y^ Predicate relation analysis^ »^ Properties about the values thatpredicates can take on^ »^ Disjoint

= 2 predicates nevertrue at the same time » Superset^ = 1 predicate truemore often » Subset = 1 predicate true lessoften » Predicate query system

Y^ Predicate-sensitive dataflowanalysis^ »^ Calculate dataflow informationon predicated code^ »^ GEN/KILL now occur on acertain predicate (not always)

t = pclearx =p,q = cmpp.uc.un (a<b)t = cmpp.oc(a<b)x =^

if p x =^

if q r,s = cmpp.un.uc(c!=d)

if q t = cmpp.on(c!=d)

if q x =^

if s = y^

if r = x^

if t = x

  • 13 -

Predicate Relation Analysis^ Y^ Execution trace

  • record of boolean

values assigned to predicates duringan execution of a predicate block^ »^ 1 = all execution traces Y Execution set

for predicate p – set

of traces in which p is True^ »^ Denoted as P^ »^ P is a subset of 1 Y Code segment^ »^ Execution traces^ y^ trace^

p^ q^ r^ s^ t y e1 (^1 0 0 0 1) y e2 (^0 1 1 0 1) y e3 (^0 1 0 1 0) » Execution sets y P = {e1}, Q = {e2,e3}, R = {e2}, S= {e3}, T = {e1,e2}, 1 ={e1,e2,e3}

t = pclear x = p,q = cmpp.uc.un (a<b) t = cmpp.oc(a<b) x =^

if p x =^

if q r,s = cmpp.un.uc(c!=d)

if q t = cmpp.on(c!=d)

if q x =^

if s = y^

if r = x^

if t = x

p^ q r^ s t

  • 15 -

Class Problem – Create the Execution Sets^ r = pclear^ x =^ p,q = cmpp.un.uc (a == b)^ x =^

if p

x =^

if q

r,s = cmpp.on.uc(c < d)

if p

r,t = cmpp.on.uc(e > f)

if s

u,v = cmpp.un.uc

if r

x =^

if s

x =^

if v

= x^

if r

x =^

if t

= x^ What is r + t??

  • 16 -

Partitioning by a CMPP^ Y^ m,n = cmpp.un.uc (i < k) if u^ »^ If m or n is true, then u must be true^ »^ If m is true, then n must be false (+ the reverse)^ »^ If u is true, then one of m or n is true^ »^ If u is false, then both m and n are false^ Y^ Execution sets^ »^ M union N <= U^ »^ M intersect N = Null^ »^ U <= M union N^ Y^ U is partitioned into disjoint subsets M and N, U = M | N

u m n

  • 18 -

Generating Partition Relations

symbol^ string

source 0 1 2 3 4 5 6 Predicate computations reordered to follow the paper p = !(a < b) * true q = (a < b) * true t1 = false t2 = t1 + !(a<b) * true t3 = t2 + (c != d) * q s = !(c != d) * q r = (c != d) * q

symbol^ string

source 0 false

false,t 1 true^

true 2 !(a<b)*

p,t 3 (a<b)*

q^

4 !(c=d)*

r 5 (c=d)*

s^

6 2+^

t3^ 6 = 2|

  • 19 -

Partition Graph^ Y^ Partition Graph

  • Directed

acyclic graph where nodesrepresent execution sets andedges represent partitionrelations between nodes^ »^ U = M | N^ »^ Edge from U to M^ »^ Edge from U to N^ »^ UÆM and U

ÆN denoted tocome from same partition

Y^ Complete

  • Contains a uniquenode having no predecessorsfrom which all nodes arereachable

p = (a<b) * true q = !(a<b) * true r = (c>d) * p s = !(c>d) * p u = (e!=5) * true v = !(e!=5) * true^1 p^ q^

u^ v r^ s