180 likes | 436 Views
Optimistic Register Coalescing. Sobeeh Almukhaizim UC San Diego Computer Science & Engineering Based on the work of: J. Park and S. Moon School of Electrical Engineering Seoul National University. Outline. Motivation and problem definition. Register Allocation Copy Coalescing
E N D
Optimistic Register Coalescing Sobeeh Almukhaizim UC San Diego Computer Science & Engineering Based on the work of: J. Park and S. Moon School of Electrical Engineering Seoul National University
Outline • Motivation and problem definition. • Register Allocation • Copy Coalescing • Optimistic Coalescing • Aggressive coalescing. • Live range splitting. • Experimental Results and Analyses • Summary
Motivation and problem definition. • Register allocation and copy coalescing. • Goal: Minimize number of registers for a program ( faster execution ). • Live range variables that interfere with each other interference graph with minimum color k ( number of registers ). • NP-complete search for heuristics.
Register Allocation • Interference Graph • A node represents a live range • An edge represents concurrent liveness • Coloring Theorem • In a graph G, a node x with degree lower than k will have a color no matter how G-{x} is colored
Register Allocators • Yorktown Allocator (Chaitin et. al) • Spills a node whenever every node is significant • Optimistic Coloring Register Allocator (Briggs et. al) • Delays spill decision later • Differentiates potential-spill and actual-spill
Copy Coalescing • Coalescing in Graph Coloring • Merging two non-interfering nodes • Makes two nodes have the same color • Effective for copy elimination • Copy Coalescing • Merging two non-interfering copy-related nodes • Makes copies meaningless • Includes both negative and positive impact on colorability
Coalescing Impact on Colorability • Negative Impact • Produce higher-degree coalesced nodes • Positive Impact • Reduce the degrees of neighbors by one 2 1 1 2 a b ad b a b ab k=2 1 c d c c d c d Positive Impact Negative Impact
Previous Coalescing Heuristics • Aggressive Coalescing(Chaitin et. al) • Coalesce any non-interfering copy operands • Conservative Coalescing(Briggs et. al) • Coalesce if the coalesced node will not be potentially-spilled • Iterated Coalescing(George and Appel) • Repeat simplification and conservative coalescing Aggressive Conservative Iterated Copy Removal best worst mid Positive Impact big small mid Negative Impact big none none
Optimistic Coalescing • Aggressive Coalescing • Live Range Splitting Motivation of Optimistic Coalescing Copy Removal Aggressive Coalescing Positive Impact Optimistic View Negative Impact Live Range Splitting
d d c 1 h 2 f 3 e 1 g 3 d 2 a 3 b spill k=3 bc 1 h 2 f 3 e 2 g 1 d 3 a 2 b e e g g bc a a f h c f h stack stack Aggressive Coalescing • Advantages of Aggressive Coalescing • Removes many copies • Fully exploits the positive impact • Optimistically, aggressively coalesced node is not necessarily spilled
Live Range Splitting • Compensate for Negative Impact • What to Split • Coalesced live ranges • When to Split • At the color phase before spilling them actually • How to Split • Reproduce the primitive live ranges by undoing coalescing
Example of Live Range Splitting a k=3 e b e stack abcd f d f g c g Graph simplification Aggressive coalescing ab=3 e=1 e=1 d f=2 f=2 c=1 g=3 g=3 Allocation result
Register Allocator Implementation • Base-case allocator • Yorktown allocator with aggressive coalescing • Briggs’ allocators with four different heuristics • with conservative coalescing (conservative) • with iterated coalescing (iterated) • with aggressive coalescing (aggressive) • with optimistic coalescing (optimistic)
Experimental Results Ratio of removed copies Ratio of introduced spill ops
Analysis of Aggressive Coalescing and Spilling • Due to aggressiveness, aggressive coalescing coalesces 66.0% more nodes • Due to optimistic view, aggressive coalescing spills only 5.6% of aggressively coalesced nodes • Due to live range splitting, optimistic coalescing reduces spills by 2.4%
Analysis of Live Range Splitting • Due to live range splitting, 52% of otherwise spilled nodes are colored
Analysis of Positive impact • Due to positive impact, coalescing removes interference edges • Optimistic coalescing exploits 3.8 times more positive impact than iterated coalescing
Summary • Optimistic Coalescing • Aggressive coalescing • Aggressive copy elimination • Positive impact • Optimistic view • Live range splitting • Reduce negative impact