This preview shows pages 1–3. Sign up to view the full content.
Data Flow Analysis and Optimizations
Last Time
•
Control Flow Graphs
Today
•
Data Flow Analysis
•
Data Flow Frameworks
•
Constant Propagation
•
Reaching Defnitions
CS 380C Lecture 3
1
Data Flow Analysis
Data Flow Analysis
Data ±ow analysis tells us things we want to know
about programs, ²or example:
•
Is this computation loop invariant?
•
Which defnition reaches this use?
•
Is this value a constant?
Example:
B = 2
A = 3
C = A + B
X = true
if (X)
then
else
A = 2
B = 3
CS 380C Lecture 3
2
Data Flow Analysis
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentData Flow Analysis
Systems of equations that compute information (e.g.,
uses, deFnitions, values) about variables at program
points.
A
Monotone Data Flow Framework
•
point
 start and/or end of a basic block
•
Information for a forward problem
IN±O
in
(
v
)
= merge (IN±O
out
predecessors
(
v
)
)
IN±O
out
(
v
)
= transfer (IN±O
in
(
v
)
)
•
Transfer functions:
T
v
is the transfer function for
v
,howin
fo
rmat
ionis
changed by
v
.
T
q
is the transfer function for a path and describes
how information is carried on path
q
.A
l
lpa
th
s
start at the entry
entry
.
Given Q:
entry
+
→
x
,where
x
is a node in the C±G,
such that
Q
=
q
o
→
q
1
→
...
q
n
,the
transfer function
is:
t
q
n

1
(
t
q
n

2
(
(
t
2
(
t
1
(
t
0
(
±
)))
)
Meet Over All Paths Solution
mop
(
x
)=
²
Q
∈
Pat hs
(
x
)
t
Q
(
±
)
CS 380C Lecture 3
3
Data ±low Analysis
Data Flow Framework
1. A
semilattice
L
with a binary meet operation
²
,
such that
a
,
b
,
c
∈
L
:
•
a
²
a
=
a
(
idempotent
)
•
a
²
b
=
b
²
a
(
commutative
)
•
a
²
(
b
²
c
)=(
a
²
b
)
²
c
(
associative
)
2.
²
imposes an order on
L
,
∀
a
,
b
∈
L
•
a
³
b
⇔
a
²
b
=
b
•
a
´
b
⇔
a
³
b
and
a
µ
=
b
3. A semilattice has a
bottom
element
⊥
,
if
•
a
²⊥
=
⊥
for every
a
∈
L
.
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 03/09/2012 for the course CS 380 taught by Professor Shmat during the Fall '08 term at University of Texas at Austin.
 Fall '08
 shmat

Click to edit the document details