























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Mahlke; Class: Advanced Compilers; Subject: Electrical Engineering And Computer Science; University: University of Michigan - Ann Arbor; Term: Winter 2004;
Typology: Study notes
1 / 31
This page cannot be seen from the preview
Don't miss anything!
























Y^ All-path: Definition guaranteed to reach^ »^ Regardless of sequence of branches taken, def reaches^ »^ Can always count on this^ »^ Only 1 def can be guaranteed to reach^ »^ Availability (as opposed to reaching)^ y^ Available definitions^ y^ Available expressions (could also have reaching expressions, but notthat useful)
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
for^ each basic block in the procedure, X, do^ GEN(X) = 0^ KILL(X) = 0^ for^ each operation in sequential order in X, op, do^ for^ each destination operand of op, dest, do^ G = op^ K = {all ops which define dest – op}^ GEN(X) = G + (GEN(X) – K)^ KILL(X) = K + (KILL(X) – G)^ endfor^ endfor endfor
7: r7 = 0 8: r1 = r1 + 5 9: r7 = r1 - 6 10: r8 = r7 + r8 11: r1 = r3 – r8 12: r3 = r1 * 2
is a RHS of an operation »^ r2 = r3 + r4, r3+r4 is an expression Y An expression e is available
at a point p if along all
paths
from e to p, e is not killed Y An expression is killed
between 2 points when one of its source operands are redefined^ »^ r1 = r2 + r3 kills all expressions involving r1 Y Algorithm^ »^ Forward dataflow analysis as propagation occurs from defsdownwards^ »^ Use the Intersect function as the meet operator to guarantee theall-path requirement^ »^ Looks exactly like adefs, except GEN/KILL/IN/OUT are theRHS’s of operations rather than the LHS’s
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
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 x =a < b x = x =c != d^ = y^
x = = x^ = x
True True False u False p q
s r t v
u
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
trace^ p^ q^ r^ s t e1^1 0 0
1 e2^0 1 1
1 e3^0 1 0
0 P = {e1},Q = {e2,e3},R = {e2}S = {e3}T = {e1,e2}1 = {e1,e2,e3}P + S = {e1} + {e3} = {e1,e3}T – P = {e1,e2} – {e1} = {e2}
u m n
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
t1 = false x =^
if true p = !(a < b) * true q = (a < b) * true t2 = t1 + !(a<b) * true x =^
if p x =^
if q r = (c != d) * q s = !(c != d) * q t3 = t2 + (c != d) * q x =^
if s = y^
if r = x^
if t = x^
if true Note: t2 = p