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.
- 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 Scholar
- 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 ScholarDigital Library
- 3.C.K. Burmeister, K. W. Harris, W. B. Noyce and S. O. Hobbs, U.S. patent number 5,339,428.Google Scholar
- 4.G. Chaitin et al., "Register Allocation via Coloring," Computer Languages, 6, pp. 47-57, 1981.Google ScholarDigital Library
- 5.G.J. Chaitin, "Register Allocation and Spilling via Graph Coloring," SIGPLAN Notices, 17(6):201-107, June 1982. Google ScholarDigital Library
- 6.M.F. Fernandez, "Simple and Effective Link-time Optimization of Modula-3 Programs," SIGPLAN Notices, 30(6):103-115, June 1995. Google ScholarDigital Library
- 7.L. George and A. Appel, "Iterated Register Coalescing,'' A CM Transactions on Programming Languages and Systems, 18(3):300-324, May 1996. Google ScholarDigital Library
- 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 ScholarDigital Library
- 9.S.O. Hobbs, Personal communication, July 1997.Google Scholar
- 10.U. Hoeltze, "Adaptive Optimization for Self: Reconciling High Performance with Exploratory Programming," Ph.D. thesis, Stanford University, March 1995.Google Scholar
- 11.B. Leverett, "Register Allocation in Optimizing Compilers,'' Ph.D. thesis, CMU-CS-81-103, Carnegie-Mellon University, February 1981. Google ScholarDigital Library
- 12.R. Morgan, Building an Optimizing Compiler, Digital Press, Boston, 1998. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 15.D. W. Wall, "Global Register Allocation at Link Time," SIGPLftN Notices, 21(7):264-275, July 1986. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
Index Terms
- Quality and speed in linear-scan register allocation
Recommendations
Linear scan register allocation on SSA form
CGO '10: Proceedings of the 8th annual IEEE/ACM international symposium on Code generation and optimizationThe linear scan algorithm for register allocation provides a good register assignment with a low compilation overhead and is thus frequently used for just-in-time compilers. Although most of these compilers use static single assignment (SSA) form, the ...
Optimized interval splitting in a linear scan register allocator
VEE '05: Proceedings of the 1st ACM/USENIX international conference on Virtual execution environmentsWe present an optimized implementation of the linear scan register allocation algorithm for Sun Microsystems' Java HotSpot™ client compiler. Linear scan register allocation is especially suitable for just-in-time compilers because it is faster than the ...
Quality and speed in linear-scan register allocation
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,...
Comments