EECS 583 Lecture 10 Analysis of Predicated Code - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

EECS 583 Lecture 10 Analysis of Predicated Code

Description:

Read papers, present to class, class projects. 4 groups ... Are t and p disjoint? Is r a subset of p? Is s a subset of q? s {q} = ? r {s} = ? p {r,s} ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 27
Provided by: scottm3
Category:

less

Transcript and Presenter's Notes

Title: EECS 583 Lecture 10 Analysis of Predicated Code


1
EECS 583 Lecture 10Analysis of Predicated Code
  • University of Michigan
  • February 11, 2002

2
Announcements
  • HW1 due today
  • Wednes
  • Finish opti stuff from last lecture
  • ILP optimizations
  • HW2 out

3
Special-interest group signup
  • Purpose
  • Focus on 1 aspect of compiler backends in more
    depth
  • Read papers, present to class, class projects
  • 4 groups (boundaries will be blurred)
  • Control flow analysis optimization
  • Dataflow analysis optimization
  • Scheduling, register allocation, code generation
  • Mapping operations to time/resource
  • Target trimaran to a real processor (TIC6X)
  • Memory optimization
  • Improve cache performance (prefetching,
    bypassing)
  • Data layout
  • Each person will be in 1 group
  • Meet on Thurs or Fri for 1 hr every other week
  • Starting after spring break
  • Not a lecture, I will bring no slides ? Group
    discussion

4
Predicated analysis introduction
x a lt b
Which definitions of x reach each use?
u
True
False
u
t pclear x p,q cmpp.uc.un (altb) t
cmpp.oc(altb) 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
x c ! d
p
q
True
False
y
x
s
r
x
t
x
v
5
Two types of analysis
  • Predicate relation analysis
  • Properties about the values that predicates can
    take on
  • Disjoint 2 predicates never true at the same
    time
  • Superset 1 predicate true more often
  • Subset 1 predicate true less often
  • Predicate query system
  • Predicate-sensitive dataflow analysis
  • Calculate dataflow information on predicated code
  • GEN/KILL now occur on a certain predicate (not
    always)

t pclear x p,q cmpp.uc.un (altb) t
cmpp.oc(altb) 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
6
Execution traces/sets
  • Execution trace record of boolean values
    assigned to predicates during an execution of a
    predicate block
  • 1 all execution traces
  • Execution set for predicate p set of traces in
    which p is True
  • Denoted as P
  • P is a subset of 1
  • Code segment
  • Execution traces
  • trace p q r s t
  • e1 1 0 0 0 1
  • e2 0 1 1 0 1
  • e3 0 1 0 1 0
  • Execution sets
  • P e1, Q e2,e3, R e2, S e3, T
    e1,e2, 1 e1,e2,e3

t pclear x p,q cmpp.uc.un (altb) t
cmpp.oc(altb) 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
7
Partitioning by a CMPP
  • m,n cmpp.un.uc (i lt k) if u
  • If m or n is true, then u must be true
  • If m is true, then n must be false ( the
    reverse)
  • If u is true, then of of m or n is true
  • If u is false, then both m and n are false
  • Execution sets
  • M union N lt U
  • M intersect N Null
  • U lt M union N
  • U is partitioned into disjoint subsets M and N, U
    M N

u
m
n
8
Predicate expressions
  • Predicate expression Execution set that is a
    derived by combining the execution sets of
    individual predicates using operators sum(),
    difference(-), product()

9
Single-target sequential SSA form
t pclear x p,q cmpp.uc.un (altb) t
cmpp.oc(altb) 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
t1 false x if true p !(a lt b) true q
(a lt b) true t2 t1 !(altb) 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 t3 x if true
Note t2 p
10
Generating partition relations
symbol string source 0 1 2 3 4 5 6
Predicate computations reodered to follow
the paper
p !(a lt b) true q (a lt b) true t1
false t2 t1 !(altb) true t3 t2 (c ! d)
q s !(c ! d) q r (c ! d) q
symbol string source 0 false false,t1 1 true
true 2 !(altb)1 p,t2 3 (altb)1 q 1
23 4 !(cd)3 r 5 (cd)3 s 3
45 6 24 t3 6 24
11
Partition graph
  • Partition Graph - Directed acyclic graph where
    nodes represent execution sets and edges
    represent partition relations between nodes
  • U M N
  • Edge from U to M
  • Edge from U to N
  • U?M and U?N denoted to come from same partition
  • Complete Contains a unique node having no
    predecessors from which all nodes are reachable

p (altb) true q !(altb) true r (cgtd)
p s !(cgtd) p u (e!5) true v !(e!5)
true
1
p
q
u
v
r
s
12
Partition graph properties
  • Root unique node with no predecessors
  • Leaf node with no successors
  • Ancestor of P any node on path from root to P
  • Descendant of P any node reachable from P
  • Level shortest-path distance from root
  • Level(root) 0
  • Lowest common ancestor node with largest level
    from the common ancestors

p (altb) true q !(altb) true r (cgtd)
p s !(cgtd) p u (e!5) true v !(e!5)
true
1
p
q
u
v
r
s
13
Partition graph of earlier example
symbol string source 0 false false,t1 1 true
true 2 !(altb)1 p,t2 3 (altb)1 q 1
23 4 !(cd)3 r 5 (cd)3 s 3
45 6 24 t3 6 24
true
6
p
q
r
s
This graph is not complete, no unique
root Solution synthesize additional partitions
that are consistent with already existing
partitions
14
Synthesizing new partitions
1
1
6
6
p
q
p
q
r
s
r
s
lca(p,r) 1 1 6 1 (p r) 1 p r s
Identify partition, U MN where U is not
reachable from 1 If M,N are reachable from 1,
then there exists a partition lca(M,N) UV,
where V is the relative complement of U with
respect to lca(M,N)
15
PQS Basic functions on pred exprs
  • lub_sum(P,E) expression representing a smallest
    superset of the execution set PE
  • glb_sum(P,E) expression representing a greatest
    subset of the execution set PE
  • Used for GEN function
  • x live under E, after use under P, x used under
    EP
  • Liveness any path, over approximation of
    execution set is conservative, thus use lub_sum
  • lub_diff(E,P) an expression representing a
    smallest superset of the execution set E-P
  • glb_diff(E,P) an expression representing a
    greatest subset of the execution set E-P
  • Used for KILL function
  • x live under E, after a DEF of x under P, x now
    live under E-P
  • Again, lub_diff an over approximation for any
    path problem like liveness

16
PQS Basic functions (2)
  • is_disjoint(P,E) true if the execution set PE
    NULL
  • Property holds for some execution at a point
    under a predicate
  • 1 x y z if p
  • 2 t x if q
  • 1 reaches 2 as long as p and q are not disjoint
  • is_subset(P,E) true if P is a subset of the
    execution set represented by E
  • Property holds for all executions at a point
    under a predicate
  • x y z if p
  • t y z if q
  • yz available at the 2nd operation only if q is a
    subset of p

17
Representing predicate expressions
  • 1-disjunctive normal form (1-dnf)
  • Restrict predicate expressions to simple form
  • Code efficiency, complexity
  • Make conservative approximations when form does
    not allow the exact answer to be expressed
  • Disjunctions of individual symbols
  • P Q

18
Implementing PQS functions in 1-dnf
1
is_disjoint(p,q) if there is a partition with p
on 1 side, q on the other, then disjoint is_subse
t(p,q) if q is an ancestor, then p is a
subset lub_sum(p, E) return p qi for all
qi in E. (Remove redundant/subsumed terms)
t
p
q
r
s
Examples Are p and s disjoint? Are t and p
disjoint? Is r a subset of p? Is s a subset of
q? s q ? r s ? p r,s ?
19
Implementing PQS functions in 1-dnf (2)
lub_diff(E, p) return Sum(qi-p) for all qi in
E. 4 subcases 1. qi lt p ? qi removed, E
NULL 2. p lt qi ? E rel_cmpl(p,qi) 3.
p,qi disjoint ? E qi 4. otherwise ? E
approx_diff(p,q) / q p / approx_diff(p,q)
relative_complement(p, lca(p,q)) relative_comple
ment(p,q) find a path from q to p E
false for each edge r? s on path do
let R STi be the partition containing r? s
add Ti to E return E
1
t
p
q
r
s
Examples q r ? q p ? t r
? t s ?
20
Predicate-sensitive dataflow analysis
  • Use liveness as representative example
  • Representation without predicates
  • On region entry/exit edges
  • Set of live variables, r1, r4, r10, r11
  • Could represent as a bitvector
  • Now with predicates
  • Variable no longer live/not-live
  • Live for a set of executions
  • For each variable, have predicate expression in
    each set
  • Bitvector becomes vector of predicate expressions

21
Predicate-sensitive liveness
Destination operands
GEN
GEN(x) GEN(x) Q KILL(x) KILL(x) Q
x y 1 if q
Source (data) operands
GEN(y) GEN(y) Q KILL(y) KILL(y) - Q
GEN
Source (predicate) operands
backward analysis
GEN(q) GEN(q) true true KILL(q) KILL(q)
true false
lub_sum - lub_diff
22
What about UN/UC CMPPs?
Destination operands
GEN
GEN(p) GEN(p) true false KILL(p)
KILL(p) true true
p cmpp.un(alt1) if q
Source (data) operands
GEN(a) GEN(a) true true KILL(a) KILL(a)
true false
GEN
Source (predicate) operands
backward analysis
GEN(q) GEN(q) true true KILL(q) KILL(q)
true false
23
What about ON/OC CMPPs?
Destination operands
GEN
GEN(p) GEN(p) (alt1)Q KILL(p) KILL(p)
(alt1)Q
p cmpp.on(alt1) if q
Source (data) operands
GEN(a) GEN(a) Q KILL(a) KILL(a) Q
GEN
Source (predicate) operands
backward analysis
GEN(q) GEN(q) true true KILL(q) KILL(q)
true false
24
Liveness example
1
t pclear x p,q cmpp.uc.un (altb) t
cmpp.oc(altb) 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
t
p
q
r
s
1. GEN(x,y) false, KILL(x,y) true
2. GEN(x) t, KILL(x) s
3. GEN(y) r, KILL(y) ps
backward analysis
4. GEN(x) t, KILL(x) s
5. GEN(x) p, KILL(x) q
6. GEN(x) false, KILL(x) true
7. GEN(x) false, KILL(x) true
25
Global predicate analysis
  • Compute local GEN/KILL info
  • Derive predicate expression per variable via
    backwards walk of the operations
  • Round predicate expression to T/F at the block
    entrance
  • If GEN(x) ! false, GEN(x) true, else false
  • If KILL(x) true, KILL(x) true, else false
  • Conservative
  • But, global solver does not need to know about
    predicates !!
  • Can also extend entire global solver to use
    predicate expressions
  • More accurate
  • Slower
  • Elcor uses the approximate method

26
Problem of the day
q pclear if true x if true p,q
cmpp.un.oc (altb) if true x if p r,q
cmpp.un.oc(c!d) if p x if r x if q
x if true
Draw partition graph Compute liveness GEN/KILL
of x at each point in the block Compute UD chain
for x if q
Write a Comment
User Comments (0)
About PowerShow.com