




























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: Assignment; Professor: Mahlke; Class: Advanced Compilers; Subject: Electrical Engineering And Computer Science; University: University of Michigan - Ann Arbor; Term: Winter 2006;
Typology: Assignments
1 / 36
This page cannot be seen from the preview
Don't miss anything!





























Reading Material^ Y^ Today’s class
Homework Problem from Lecture 5 (Cont)
Assume Left edges are negative and Right edges are positive CD(1) =
φ CD(2) = -1 CD(3) = -2 CD(4) = -3 CD(5) = +2,+3 CD(6) = -4 CD(7) = +4 CD(8) = -1 CD(9) =
φ
u = v + 1 x = y + 1
b > 0 c > 0
a <= 0
b <= 0 c <= 0 d <= 0
BB1 d > 0 BB3 BB^
a > 0 BB2 r = t + s z = z + 1
Homework Problem from Lecture 5 (Cont)
Predicate assignment (K set) BB1 BB2 BB3 BB4 BB5 BB6 BB7 BB8 BB9 True p
p^
p3^ p
p^
p6^ p
True
Predicates (R set) -1 -2 -3 +2,+3 -4 +4 p1 p2 p
p^
p5 p
DU/UD Chains^ Y^ Convenient way to access/use reaching defs info^ Y^ Def-Use chains » Given a def, what are all the possible consumers of theoperand produced » Maybe consumer Y Use-Def chains » Given a use, what are all the possible producers of theoperand consumed » Maybe producer
Example – DU/UD Chains
r1 = 3 r2 = r3 r3 = r4 r1 = r1 + 1 r7 = r1 * r r4 = r4 + 1
r4 = r r8 = 8 r9 = r7 + r
DU/UD Chains in Elcor (2)^ Y^ Region-level analysis »^ Efficiency – just analyze overwhat you are interested in »^ What about uses/defs outside theregion of analysis?? »^ Can’t have direct connection, orits not region analysis »^ But, can’t ignore them Y External def/use refs »^ El_ref has a type^ y^
EXP_SRC, EXP_DEST(explicit) y IMP_SRC, IMP_DEST (implicit) y LIVEIN_DEST (outside def) y LIVEOUT_SRC (outside use) Y^ Use global liveness info to createexternal def/use refs Y^ UD/DU chains contain both insideand outside refs
1: r1 = MEM[r2+0] 2: r2 = r2 + 1 3: r3 = r1 * r 4: r1 = r1 + 5 5: r3 = r5 – r1 6: r7 = r3 * 2
7: r7 = r6 8: r2 = 0 9: r7 = r7 + 1 10: r8 = r7 + 5 11: r1 = r3 – r8 12: r3 = r1 * 2
Some Things to Think About^ Y^ Liveness and rdefs are basically the same thing
Meaning of gen/kill – src vs dest, variable vs operation y Backward / Forward y All paths / some paths (must/may)^ X^ So far, we have looked at may analysis algorithms^ X^ How do you adjust to do must algorithms?
Beyond Liveness or Upward Exposed Uses^ Y^ Upward exposed defs »^ IN = GEN + (OUT – KILL) »^ OUT = Union(IN(successors)) »^ Walk ops reverse order^ y^
GEN += dest; KILL += dest
IN = Union(OUT(predecessors)) » OUT = GEN + (IN-KILL) » Walk ops forward order^ y^ GEN += src; KILL -= src;^ y^ GEN -= dest; KILL += dest;
IN = Union(OUT(predecessors)) » OUT = GEN + (IN-KILL) » Walk ops forward order^ y^ GEN += dest; KILL += dest;
» IN = Union(OUT(predecessors)) » OUT = GEN + (IN-KILL) » Walk ops forward order^ y GEN += src; KILL -= src;^ y GEN -= dest; KILL += dest;
- r = t + s b > 0 c > 0 u = v + 1 x = y + r = t + s if (b > 0 || c > 0) u = v + 1 else if (d > 0) x = y + 1 else z = z + 1 } a. Draw the CFGb. Compute CDc. If-convert the code - a <= - b <= 0 c <= 0 d <= 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 – r
1,2,3,4 reach1 available
1,2 reach 1,2 available
1,3,4 reach 1,3,4 available
Available Definition Analysis (Adefs)^ Y^ A definition d is available
Initialization of IN/OUT is the tricky part
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
Example Adefs Calculation
1: r1 = MEM[r2+0] 2: r2 = r2 + 1 3: r3 = r1 * r 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