Professional Documents
Culture Documents
Lecture 25
• Cache Management
{b}
CS 536 Spring 2001 10
The Register Interference Graph
c
e
d
• E.g., b and c cannot be in the same register
• E.g., b and d can be in the same register
r2 e c r4
d r3
• There is no coloring with less than 4 colors
• There are 4-colorings of this graph
CS 536 Spring 2001 16
Graph Coloring. Example.
r2 := r3 + r4
r3 := -r2
r2 := r3 + r1
r3 := r3 + r2
r1 := 2 * r2
r2 := r2 - 1
r3 := r1 + r4
• Observation:
– Pick a node t with fewer than k neighbors in RIG
– Eliminate t and its edges from RIG
– If the resulting graph has a k-coloring then so does
the original graph
• Why:
– Let c1,…,cn be the colors assigned to the neighbors
of t in the reduced graph
– Since n < k we can pick some color for t that is
different from those of its neighbors
d
• Remove a and then d
r2 e c r4
d r3
a
b
f
c
e
d
CS 536 Spring 2001 24
What if the Heuristic Fails?
b
f
c
e
d
CS 536 Spring 2001 25
What if the Heuristic Fails?
c
e
d
CS 536 Spring 2001 26
What if the Heuristic Fails?
b r3
? f
c r1
r2 e
d r3
CS 536 Spring 2001 27
Spilling
f := 2 * e b := d + e
store f, fa e := e - 1
f := load fa
b := f + c
c
e
d
CS 536 Spring 2001 32
Spilling (Cont.)