skip to main content
research-article

Copy coalescing by graph recoloring

Published:07 June 2008Publication History
Skip Abstract Section

Abstract

Register allocation is always a trade-off between live-range splitting and coalescing. Live-range splitting generally leads to less spilling at the cost of inserting shuffle code. Coalescing removes shuffle code while potentially raising the register demand and causing spilling.

Recent research showed that the live-range splitting of the SSA form's Æ-functions leads to chordal interference graphs. This improves upon two long-standing inconveniences of graph coloring register allocation: First, chordal graphs are optimally colorable in quadratic time. Second, the number of colors needed to color the graph is equal to the maximal register pressure in the program. However, the inserted shuffle code incurred by the Æ-functions can slow down the program severely. Hence, to make such an approach work in practice, a coalescing technique is needed that removes most of the shuffle code without causing further spilling.

In this paper, we present a coalescing technique designed for, but not limited to, SSA-form register allocation. We exploit that a valid coloring can be easily obtained by an SSA-based register allocator. This initial coloring is then improved by recoloring the interference graph and assigning shuffle-code related nodes the same color. Thereby, we always keep the coloring of the graph valid. Hence, the coalescing is safe, i. e. no spill code will be caused by coalescing.

Comparing to iterated register coalescing, the state of the art in safe coalescing, our method is able to remove 22.5% of the costs and 44.3% of the copies iterated coalescing left over. The best solution possible, found by a colaescer using integer linear programming (ILP), was 35.9% of the costs and 51.9% of the copies iterated coalescing left over. The runtime of programs compiled with our heuristic matches that of the programs compiled with the ILP technique.

References

  1. Andrew W. Appel and Lal George. Optimal Spilling for CISC Machines with Few Registers. In ACM SIGPLAN 2001 Conference on Programming Language Design and Implementation, pages 243--253, June 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Florent Bouchez, Alain Darte, Christophe Guillon, and Fabrice Rastello. Register Allocation: What does the NP-Completeness Proof of Chaitin et al. really prove? or revisiting Register Allocation: Why and How? In 19th International Workshop on Languages and Compilers for Parallel Computing (LCPC'06), New Orleans, USA, Nov 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Florent Bouchez, Alain Darte, and Fabrice Rastello. On the Complexity of Register Coalescing. In International Symposium on Code Generation and Optimization (CGO'07), San Jose, USA, March 2007. IEEE Computer Society Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Preston Briggs, Keith D. Cooper, and Linda Torczon. Improvements to Graph Coloring Register Allocation. ACM Transactions on Programming Languages and Systems, 16(3):428--455, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Preston Briggs, Keith D.Cooper, Timothy J. Harvey, and L. Taylor Simpson. Practical Improvements to the Construction and Destruction of Static Single Assignment Form. Software: Practice and Experience, 28(8):859--881, July 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Philip Brisk, Foad Dabiri, Roozbeh Jafari, and Majid Sarrafzadeh. Optimal Register Sharing for High-Level Synthesis of SSA Form Programs. IEEE Trans. on CAD of Integrated Circuits and Systems, 25(5):772--779, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. G. J. Chaitin, M. A. Auslander, A. K. Chandra, J. Cocke, M. E. Hopkins, and P. W. Markstein. Register allocation via graph coloring. Journal of Computer Languages, 6:45--57, 1981.Google ScholarGoogle Scholar
  8. Standard Performance Evaluation Corporation. SPEC CPU2000 V1.3. http://www.spec.org/cpu2000/.Google ScholarGoogle Scholar
  9. R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadek. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems, 13(4):451--490, October 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Janet Fabri. Automatic Storage Optimization. In SIGPLAN '79: Proceedings of the 1979 SIGPLAN Symposium on Compiler Construction, pages 83--91, New York, NY, USA, 1979. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Lal George and Andrew W. Appel. Iterated Register Coalescing. ACM Transactions on Programming Languages and Systems, 18(3):300--324, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Daniel Grund and Sebastian Hack. A Fast Cutting-Plane Algorithm for Optimal Coalescing. In Shriram Krishnamurthi and Martin Odersky, editors, Compiler Construction, volume 4420 of Lecture Notes In Computer Science, pages 111--115, March 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Sebastian Hack. Register Allocation for Programs in SSA Form. PhD thesis, Universität Karlsruhe, October 2007.Google ScholarGoogle Scholar
  14. Sebastian Hack, Daniel Grund, and Gerhard Goos. Register Allocation for Programs in SSA Form. In Andreas Zeller and Alan Mycroft, editors, Compiler Construction, volume 3923, pages 247--262. Springer, March 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. The libFirm Compiler. http://www.libfirm.org.Google ScholarGoogle Scholar
  16. Guei-Yuan Lueh, Thomas Gross, and Ali-Reza Adl-Tabatabai. Fusion-based Register Allocation. ACM Transactions on Programming Languages and Systems, 22(3):431--470, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Dániel Marx. Graph Coloring with Local and Global Constraints. PhD thesis, Budapest University of Technology and Economics, 2004.Google ScholarGoogle Scholar
  18. Robert Morgan. Building an Optimizing Compiler. Digital Press, Newton, MA, USA, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Takuya Nakaike, Tatsushi Inagaki, Hideaki Komatsu, and Toshio Nakatani. Profile-based Global Live-Range Splitting. In PLDI '06: Proceedings of the 2006 ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 216--227, New York, NY, USA, 2006. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Michael Paleczny, Christopher Vick, and Cliff Click. The Java HotSpot? Server Compiler. In Proceedings of the Java Virtual Machine Research and Technology Symposium (JVM '01), April 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Jinpyo Park and Soo-Mook Moon. Optimistic Register Coalescing. ACM Transactions on Programming Languages and Systems, 26(4):735--765, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Fernando Magno Quintão Pereira and Jens Palsberg. Register allocation via coloring of chordal graphs. In Proceedings of APLAS'05, volume 3780 of Lecture Notes In Computer Science, pages 315--329. Springer, November 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Tim A. Wagner, Vance Maverick, Susan L. Graham, and Michael A. Harrison. Accurate Static Estimators for Program Optimization. In PLDI '94: Proceedings of the ACM SIGPLAN 1994 Conference on Programming Language Design and Implementation, pages 85--96, New York, NY, USA, 1994. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Copy coalescing by graph recoloring

    Recommendations

    Reviews

    Charles Robert Morgan

    This paper is a continuation of a recent revolution in graph coloring register allocation based on the work of Chaitin and others. Chaitin's technique has two drawbacks: repeated building of an expensive data structure called the interference graph and determining which data to keep in registers when insufficient registers are available. Hack and a number of other authors determined that programs represented in static single assignment form can be colored without building the interference graph, since the interference graph is a chordal graph. Unfortunately, there is a drawback: the coloring may produce a number of register-to-register move instructions. This often occurs when two operands of an instruction must be in the same register or an operand must be in a fixed physical register. Removing these move instructions is called copy coalescing. This paper provides a more advanced algorithm for copy coalescing than was provided in Hack's thesis. It uses the move instructions to partition the set of symbolic registers. Ideally, all elements of each partition should be in the same physical register; of course, this is not always possible. It applies a recursive algorithm to adjust the color of each symbolic register. The algorithm has a number of limits built in, to avoid excessive computation. This is a promising algorithm. It was tested against the integer subset of the CPU2000 SPEC benchmark. Other programs, particularly floating-point intensive programs and machine-generated programs, have much larger basic blocks and heavier register usage. We need to see results indicating that the algorithms can realistically handle tens of thousands of symbolic registers and huge functions. Online Computing Reviews Service

    Access critical reviews of Computing literature here

    Become a reviewer for Computing Reviews.

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 43, Issue 6
      PLDI '08
      June 2008
      382 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/1379022
      Issue’s Table of Contents
      • cover image ACM Conferences
        PLDI '08: Proceedings of the 29th ACM SIGPLAN Conference on Programming Language Design and Implementation
        June 2008
        396 pages
        ISBN:9781595938602
        DOI:10.1145/1375581
        • General Chair:
        • Rajiv Gupta,
        • Program Chair:
        • Saman Amarasinghe

      Copyright © 2008 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 7 June 2008

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!