1 Optimistic Register Coalescing Sobeeh Almukhaizim UC San Diego Computer Science & Engineering Based on the work of: J. Park and S. Moon School of Electrical.

Slides:



Advertisements
Similar presentations
Register Allocation COS 320 David Walker (with thanks to Andrew Myers for many of these slides)
Advertisements

Register Allocation Consists of two parts: Goal : minimize spills
Register Usage Keep as many values in registers as possible Register assignment Register allocation Popular techniques – Local vs. global – Graph coloring.
P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
Register allocation Morgensen, Torben. "Register Allocation." Basics of Compiler Design. pp from (
Register Allocation CS 320 David Walker (with thanks to Andrew Myers for most of the content of these slides)
Idea of Register Allocation x = m[0]; y = m[1]; xy = x*y; z = m[2]; yz = y*z; xz = x*z; r = xy + yz; m[3] = r + xz x y z xy yz xz r {} {x} {x,y} {y,x,xy}
Coalescing Register Allocation CS153: Compilers Greg Morrisett.
Register Allocation Mooly Sagiv Schrierber Wed 10:00-12:00 html://
COMPILERS Register Allocation hussein suleman uct csc305w 2004.
Graph-Coloring Register Allocation CS153: Compilers Greg Morrisett.
Stanford University CS243 Winter 2006 Wei Li 1 Register Allocation.
Register Allocation CS 671 March 27, CS 671 – Spring Register Allocation - Motivation Consider adding two numbers together: Advantages: Fewer.
Carnegie Mellon Lecture 6 Register Allocation I. Introduction II. Abstraction and the Problem III. Algorithm Reading: Chapter Before next class:
From AST to Code Generation Professor Yihjia Tsai Tamkang University.
1 CS 201 Compiler Construction Lecture 12 Global Register Allocation.
Register Allocation Mooly Sagiv html://
Improving code generation. Better code generation requires greater context Over expressions: optimal ordering of subtrees Over basic blocks: Common subexpression.
Register Allocation (Slides from Andrew Myers). Main idea Want to replace temporary variables with some fixed set of registers First: need to know which.
November 29, 2005Christopher Tuttle1 Linear Scan Register Allocation Massimiliano Poletto (MIT) and Vivek Sarkar (IBM Watson)
1 Register Allocation Consists of two parts: –register allocation What will be stored in registers –Only unambiguous values –register assignment Which.
Prof. Bodik CS 164 Lecture 171 Register Allocation Lecture 19.
Code Generation for Basic Blocks Introduction Mooly Sagiv html:// Chapter
Register Allocation (via graph coloring)
CMPUT Compiler Design and Optimization1 CMPUT680 - Fall 2003 Topic 7: Register Allocation and Instruction Scheduling José Nelson Amaral
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
Register Allocation (via graph coloring). Lecture Outline Memory Hierarchy Management Register Allocation –Register interference graph –Graph coloring.
1 Liveness analysis and Register Allocation Cheng-Chia Chen.
Improving Code Generation Honors Compilers April 16 th 2002.
Improving code generation. Better code generation requires greater context Over expressions: optimal ordering of subtrees Over basic blocks: Common subexpression.
Register Allocation Recap Mooly Sagiv html:// Special Office Hours Wednesday 12-14, Thursday 12-14, Schriber.
4/29/09Prof. Hilfinger CS164 Lecture 381 Register Allocation Lecture 28 (from notes by G. Necula and R. Bodik)
Register Allocation Mooly Sagiv html://
Register Allocation and Spilling via Graph Coloring G. J. Chaitin IBM Research, 1982.
CS745: Register Allocation© Seth Copen Goldstein & Todd C. Mowry Register Allocation.
Λλ Fernando Magno Quintão Pereira P ROGRAMMING L ANGUAGES L ABORATORY Universidade Federal de Minas Gerais - Department of Computer Science P ROGRAM A.
Supplementary Lecture – Register Allocation EECS 483 University of Michigan.
An Optimistic and Conservative Register Assignment Heuristic for Chordal Graphs Philip BriskAjay K. VermaPaolo Ienne International Conference on Compilers,
Graph-Coloring Register Allocation: Beyond the Treatment in C OMP 412 1COMP 512, Rice University Copyright 2011, Keith D. Cooper & Linda Torczon, all rights.
1 October 18, October 18, 2015October 18, 2015October 18, 2015 Azusa, CA Sheldon X. Liang Ph. D. Azusa Pacific University, Azusa, CA 91702, Tel:
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Register Allocation John Cavazos University.
CMPE 511 Computer Architecture A Faster Optimal Register Allocator Betül Demiröz.
ANALYSIS AND IMPLEMENTATION OF GRAPH COLORING ALGORITHMS FOR REGISTER ALLOCATION By, Sumeeth K. C Vasanth K.
Interference Graphs for Programs in Static Single Information Form are Interval Graphs Philip Brisk Processor Architecture Laboratory (LAP) EPFL Lausanne,
Global Register Allocation via Graph Coloring Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp.
On the Relation between SAT and BDDs for Equivalence Checking Sherief Reda Rolf Drechsler Alex Orailoglu Computer Science & Engineering Dept. University.
Register Usage Keep as many values in registers as possible Keep as many values in registers as possible Register assignment Register assignment Register.
Register Allocation CS 471 November 12, CS 471 – Fall 2007 Register Allocation - Motivation Consider adding two numbers together: Advantages: Fewer.
Compiler Principles Fall Compiler Principles Lecture 12: Register Allocation Roman Manevich Ben-Gurion University.
Register Allocation: Graph Coloring Compiler Baojian Hua
2/22/2016© Hal Perkins & UW CSEP-1 CSE P 501 – Compilers Register Allocation Hal Perkins Winter 2008.
Register Allocation Ajay Mathew Pereira and Palsberg. Register allocation via coloring of chordal graphs. APLOS'05Register allocation via coloring of chordal.
Compiler Principles Fall Compiler Principles Lecture 11: Register Allocation Roman Manevich Ben-Gurion University of the Negev.
Global Register Allocation Based on
Mooly Sagiv html://
Fall Compiler Principles Lecture 9: Register Allocation
Register Allocation Hal Perkins Autumn 2009
Register Allocation Noam Rinetzky Text book:
Topic 12: Register Allocation
CSC D70: Compiler Optimization Register Allocation
Bottom-up, Graph-Coloring, Register Allocation: Beyond the Treatment in COMP 412 COMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith.
Register Allocation Hal Perkins Autumn 2011
Compiler Construction
Lecture 17: Register Allocation via Graph Colouring
Register Allocation via Coloring of Chordal Graphs
Discrete Mathematics for Computer Science
Fall Compiler Principles Lecture 13: Summary
(via graph coloring and spilling)
CS 201 Compiler Construction
Presentation transcript:

1 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

2 Motivation and problem definition. Register Allocation Copy Coalescing Optimistic Coalescing Aggressive coalescing. Live range splitting. Experimental Results and Analyses Summary Outline

3 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.

4 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 Allocation

5 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 Register Allocators

6 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

7 Coalescing Impact on Colorability Negative Impact –Produce higher-degree coalesced nodes Positive Impact –Reduce the degrees of neighbors by one a c b dd ab c 2 1 Negative Impact ab c ad d b c k=2 Positive Impact 2 1 1

8 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 AggressiveConservativeIterated Copy Removalbestworstmid Positive Impactmidsmallbig Negative Impactbignone

9 Optimistic Coalescing Aggressive Coalescing Live Range Splitting Aggressive Coalescing Live Range Splitting Copy Removal Positive Impact Negative Impact Optimistic View Motivation of Optimistic Coalescing

10 Advantages of Aggressive Coalescing –Removes many copies –Fully exploits the positive impact –Optimistically, aggressively coalesced node is not necessarily spilled Aggressive Coalescing a d ge hf bc bc 1 h 2 f 3 e 2 g 1 d 3 a 2 stack k=3 a d ge hfc b c 1 h 2 f 3 e 1 g 3 d 2 a 3 b spill stack

11 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

12 a b c f d g e k=3 e=1 f=2 g=3 Aggressive coalescing abcd e f g ab=3 c=1 f=2 d g=3 e=1 stack Graph simplification Allocation result Example of Live Range Splitting

13 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) Register Allocator Implementation

14 Ratio of removed copiesRatio of introduced spill ops Experimental Results

15 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 Aggressive Coalescing and Spilling

16 Due to live range splitting, 52% of otherwise spilled nodes are colored Analysis of Live Range Splitting

17 Due to positive impact, coalescing removes interference edges Optimistic coalescing exploits 3.8 times more positive impact than iterated coalescing Analysis of Positive impact

18 Optimistic Coalescing –Aggressive coalescing Aggressive copy elimination Positive impact Optimistic view –Live range splitting Reduce negative impact Summary