








































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
Basic Code Generation, Data Flow Analysis, Variables, DAG Representations, Interior nodes, Optimization, Labeling algorithms are basic concepts discussed of course.
Typology: Slides
1 / 48
This page cannot be seen from the preview
Don't miss anything!









































2
Liveness information allows us to keep values in registers if they will be used later (efficiency)
4
Why do we need to save live variables at the end?
We might have to reload them in the next block.
Global Data-Flow Analysis
5
A dag (directed acyclic graph)
for a basic block has the
following labels for the nodes:
7
BB DAG for x = y op z
op x
y z
8
For statement i: x = y op z if y op z node exists, add x to the label for that node. else add node for y op z. If y or z exist in the dag, point to existing locations else add leaves for y and/or z and have the op node point to them.
10
Example 1
a = b + c t1 = a * a b = t1 + a c = t1 * b t2 = c + b a = t2 + t
11
Example 1
a = b + c t1 = a * a b = t1 + a c = t1 * b t2 = c + b a = t2 + t2 (^) b c
a +
13
Example 1
a = b + c t1 = a * a b = t1 + a c = t1 * b t2 = c + b a = t2 + t2 (^) b’
t
c
b +
a
14
Example 1
a = b + c t1 = a * a b = t1 + a c = t1 * b t2 = c + b a = t2 + t2 (^) b’
t
c’
b +
a
16
Example 1
a = b + c t1 = a * a b = t1 + a c = t1 * b t2 = c + b a = t2 + t2 (^) b’
t
c’
t
b +
c
a
17
Example 2
t1 = 4 * i t2 = a[t1] t3 = 4 * i t4 = b[t3] t5 = t2 * t t6 = p + t p = t t7 = i + 1 i = t if i <20 goto (1)
a b 4 i’ 1
[ ] (^) [ ] <
p’
t6,p t t2 t t1,t3 (^) t7,i
(1) 20
19
Order 1 t1 = a + b t2 = c + d t3 = e – t t4 = t1 – t
Order 2 t2 = c + d t3 = e – t t1 = a + b t4 = t1 – t
a (^) b e + c (^) d
t
t
t t
20
Order #1 with 2 registers
t1 = a + b t2 = c + d t3 = e – t t4 = t1 – t
MOV a, R ADD b,R MOV c, R ADD D, R MOV R0,t MOV e, R SUB R1,R MOV t1,R SUB R0, R MOV R1,t ; 10 instructions