




















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
This document from the university of michigan's eecs 583 course covers local/global optimization, focusing on representing predicate expressions and predicate-sensitive dataflow analysis. The lecture discusses converting predicate expressions to 1-disjunctive normal form (1-dnf), implementing pqs functions, and predicate-sensitive liveness analysis.
Typology: Study notes
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















Representing Predicate Expressions
Code efficiency, complexity
Implementing PQS Functions in 1-dnf (2) lub_diff(E, p) = return Sum(qi-p) for all qi in E. 4 subcases
qi removed, E += NULL
E += rel_cmpl(p,qi)
E += qi
E += approx_diff(p,q)
/* q – p */ approx_diff(p,q)
relative_complement(p, lca(p,q)) relative_complement(p,q)
find a path from q to p E = false for each edge r
s on path do
let R = S|Ti be the partition
containing r
s
add Ti to E return E
1 p^
q r^
s
t
Examples: {q} – r =? {q} – p =? {t} – r =? {t} – s =?
Predicate-Sensitive Dataflow Analysis
Bitvector becomes vector of predicate expressions
What About UN/UC CMPP’s?
Destination operands
GEN’(p) = GEN(p) – true = false KILL’(p) = KILL(p) + true = true
Source (data) operands GEN’(a) = GEN(a) + true = true KILL’(a) = KILL(a) – true = false
Source (predicate) operands
backward analysis
GEN’(q) = GEN(q) + true = true KILL’(q) = KILL(q) – true = false
What About ON/OC CMPP’s?
Destination operands
GEN’(p) = GEN(p) – (a<1)Q KILL’(p) = KILL(p) + (a<1)Q
Source (data) operands GEN’(a) = GEN(a) + Q KILL’(a) = KILL(a) – Q
Source (predicate) operands
backward analysis
GEN’(q) = GEN(q) + true = true KILL’(q) = KILL(q) – true = false
Global Predicate Analysis
If GEN(x) != false, GEN(x) = true, else = false y If KILL(x) = true, KILL(x) = true, else = false y Conservative y But, global solver does not need to know about predicates !!
More accurate y Slower y Elcor uses the approximate method
Class Problem^ 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 Compute liveness GEN/KILL of x at each point in the block Compute UD chain for “=x if True”, “=x if r”
Classical Optimizations Y
Constant folding, strength reduction
Y
Y
Constant propagation »^
Forward copy propagation »^
Backward copy propagation »^
Constant combining »^
Operation folding
Y
Invariant code removal »^
Global variable migration »^
Induction variable strength reduction »^
Induction variable elimination
Caveat
Strength Reduction
r1 = r2 * 8
r1 = r2 << 3
r1 = r2 / 4
r1 = r2 >> 2
r1 = r2 REM 16
r1 = r2 & 15
r1 = r2 * 6
X^
r100 = r2 << 2; r101 = r2 << 1; r1 = r100 + r
y^
r1 = r2 * 7^ X
r100 = r2 << 3; r1 = r100 – r
Dead Code Elimination Y
Y
X can be deleted^ y
no stores or branches
DU chain empty or destregister not live
Y
Especially in loops »^
Critical operation^ y
store or branch operation
Any operation that does notdirectly or indirectly feed acritical operation is dead »^
Trace UD chains backwardsfrom critical operations »^
Any op not visited is dead
r1 = 3 r2 = 10 r4 = r4 + 1 r7 = r1 * r
r2 = 0
r3 = r3 + 1
r3 = r2 + r1 store (r1, r3)
Constant Propagation Y
rx = L (where L is a literal) »^
Maximally propagate »^
Assume no instructionencoding restrictions
Y
SRC: Literal is a hard codedconstant, so never a problem »^
DEST: Must be available^ y
Guaranteed to reach y^
May reach not good enough
r1 = 5r2 = r1 + r
r1 = r1 + r
r7 = r1 + r
r8 = r1 + 3
r9 = r1 + r
Local Constant Propagation Y
When dest(X) is a Macroreg, BRL destroys the value