article

Quality and speed in linear-scan register allocation

Abstract

A linear-scan algorithm directs the global allocation of register candidates to registers based on a simple linear sweep over the program being compiled. This approach to register allocation makes sense for systems, such as those for dynamic compilation, where compilation speed is important. In contrast, most commercial and research optimizing compilers rely on a graph-coloring approach to global register allocation. In this paper, we compare the performance of a linear-scan method against a modern graph-coloring method. We implement both register allocators within the Machine SUIF extension of the Stanford SUIF compiler system. Experimental results show that linear scan is much faster than coloring on benchmarks with large numbers of register candidates. We also describe improvements to the linear-scan approach that do not change its linear character, but allow it to produce code of a quality near to that produced by graph coloring.

References

  1. 1 D.S. Blickstein, P. W. Craig, C. S. Davidson, R. N. Faiman, K. D. Glossop, R. P. Grove, S. O. Hobbs and W. B. Noyce, "The GEM Optimizing Compiler System," Digital Equipment Corporation Technical Journal, 4(4)'121-135, 1992.Google ScholarGoogle Scholar
  2. 2 P. Briggs, K. Cooper, and L. Torczon, "Improvements to Graph Coloring Register Allocation," A CM Transactions on Programming Languages and Systems, 16(3):428-455, May 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 3 C.K. Burmeister, K. W. Harris, W. B. Noyce and S. O. Hobbs, U.S. patent number 5,339,428.Google ScholarGoogle Scholar
  4. 4 G. Chaitin et al., "Register Allocation via Coloring," Computer Languages, 6, pp. 47-57, 1981.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 5 G.J. Chaitin, "Register Allocation and Spilling via Graph Coloring," SIGPLAN Notices, 17(6):201-107, June 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 6 M.F. Fernandez, "Simple and Effective Link-time Optimization of Modula-3 Programs," SIGPLAN Notices, 30(6):103-115, June 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 7 L. George and A. Appel, "Iterated Register Coalescing,'' A CM Transactions on Programming Languages and Systems, 18(3):300-324, May 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8 L.J. Hendren, G. R. Gao, E. R. Altman and C. Mukerji, "A Register Allocation Framework Based on Hierarchical Cyclic Interval Graphs," Proc. 4th International Compiler Construction Conference, pp. 176-191, October 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 9 S.O. Hobbs, Personal communication, July 1997.Google ScholarGoogle Scholar
  10. 10 U. Hoeltze, "Adaptive Optimization for Self: Reconciling High Performance with Exploratory Programming," Ph.D. thesis, Stanford University, March 1995.Google ScholarGoogle Scholar
  11. 11 B. Leverett, "Register Allocation in Optimizing Compilers,'' Ph.D. thesis, CMU-CS-81-103, Carnegie-Mellon University, February 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 12 R. Morgan, Building an Optimizing Compiler, Digital Press, Boston, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 13 M. Poletto, D. R. Engler and M. F. Kaashoek, "tcc: a System for Fast, Flexible and High-level Dynamic Code Generation," SIGPLAN Notices, 32(5): 109-121, May 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 14 M. Smith, "Extending SUIF for Machine-dependent Optimizations," Proc. First SUIF Compiler Workshop, Stanford, CA, pp. 14-25, January 1996. URL: http:// www'eecs'harvard'edu/machsuif'Google ScholarGoogle Scholar
  15. 15 D. W. Wall, "Global Register Allocation at Link Time," SIGPLftN Notices, 21(7):264-275, July 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 16 R. Wilson et al., "SUIF: An Infrastructure for Research on Parallelizing and Optimizing Compilers," A CM SIGPLAN Notices, 29 (1994), pp. 31-37. URL: http:// suif.stanford.edu. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 17 W. Wulf, R. K. Johnsson, C. B. Weinstock, S. O. Hobbs and C. M. Geschke, The Design of an Optimizing Compiler, American Elsevier, New York, 1975. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Quality and speed in linear-scan register allocation

              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

              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!