Abstract
Register allocation is one of the most studied problems in compilation. It is considered NP-complete since Chaitin et al., in 1981, modeled the problem of assigning temporary variables to k machine registers as the problem of coloring, with k colors, the interference graph associated to the variables. The fact that this graph can be arbitrary proves the NP-completeness of this formulation. However, this original proof does not really show where the complexity of register allocation comes from. Recently, the re-discovery that interference graphs of SSA programs can be colored in polynomial time raised the question: Can we use SSA to do register allocation in polynomial time, without contradicting Chaitin et al’s NP-completeness result? To address this question and, more generally, the complexity of register allocation, we revisit Chaitin et al’s proof to identify the interactions between spilling (load/store insertion), coalescing/splitting (removal/insertion of register moves), critical edges (property of the control flow), and coloring (assignment to registers). In particular, we show that, in general, it is easy to decide if temporary variables can be assigned to k registers or if some spilling is necessary. In other words, the real complexity does not come from the coloring itself (as a misinterpretation Chaitin et al’s proof may suggest) but comes from critical edges and from the optimizations of spilling and coalescing.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Appel, A.W., George, L.: Optimal spilling for CISC machines with few registers. In: Proceedings of PLDI’01, Snowbird, Utah, USA, June 2001, pp. 243–253. ACM Press, Snowbird (2001)
Bouchez, F., et al.: Register allocation and spill complexity under SSA. Technical Report RR2005-33, LIP, ENS-Lyon, France, (Aug. 2005)
Bouchez, F., et al.: On the complexity of register coalescing. Technical Report RR2006-15, LIP, ENS-Lyon, France (Apr. 2006)
Briggs, P., Cooper, K., Torczon, L.: Improvements to graph coloring register allocation. ACM Transactions on Programming Languages and Systems 16(3), 428–455 (1994)
Briggs, P., et al.: Practical improvements to the construction and destruction of static single assignment form. Software: Practice and Experience 28(8), 859–881 (1998)
Brisk, P., et al.: Polynomial time graph coloring register allocation. In: 14th International Workshop on Logic and Synthesis, June (2005)
Budimlić, Z., et al.: Fast copy coalescing and live range identification. In: Proc. of PLDI’02, pp. 25–32. ACM Press, New York (2002)
Chaitin, G.J.: Register allocation & spilling via graph coloring. SIGPLAN Notices, Proceedings of Compiler Construction (CC’82) 17(6), 98–105 (1982)
Chaitin, G.J., et al.: Register allocation via coloring. Computer Languages 6, 47–57 (1981)
Cooper, K.D., Simpson, L.T.: Live range splitting in a graph coloring register allocator. In: Koskimies, K. (ed.) CC 1998 and ETAPS 1998. LNCS, vol. 1383, pp. 174–187. Springer, Heidelberg (1998)
Cytron, R., Ferrante, J.: What’s in a name? Or the value of renaming for parallelism detection and storage allocation. In: Proceedings of the 1987 International Conference on Parallel Processing, Aug. 1987, pp. 19–27. IEEE Computer Society Press, Los Alamitos (1987)
Cytron, R., et al.: Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems 13(4), 451–490 (1991)
Darte, A., Rastello, F.: Personal communication with Benoît Dupont de Dinechin, Jeanne Ferrante, and Christophe Guillon (2002)
Farach-Colton, M., Liberatore, V.: On local register allocation. Journal of Algorithms 37(1), 37–65 (2000)
Garey, M.R., Johnson, D.S.: Computers and Intractability: A Guide to the Theory of NP-Completeness. W.H. Freeman and Company, New York (1979)
Garey, M.R., et al.: The complexity of coloring circular arcs and chords. SIAM J. of Algebr. Discrete Methods 1(2), 216–227 (1980)
George, L., Appel, A.W.: Iterated register coalescing. ACM Transactions on Programming Languages and Systems 18(3), 300–324 (1996)
Golumbic, M.C.: Algorithmic Graph Theory and Perfect Graphs. Academic Press, New York (1980)
Hack, S., Grund, D., Goos, G.: Register allocation for programs in SSA-form. In: Mycroft, A., Zeller, A. (eds.) CC 2006 and ETAPS 2006. LNCS, vol. 3923, Springer, Heidelberg (2006)
Knobe, K., Zadeck, K.: Register allocation using control trees. Technical Report No. CS-92-13, Brown University (1992)
Leung, A., George, L.: Static single assignment form for machine code. In: Proceedings of PLDI’99, pp. 204–214. ACM Press, New York (1999)
Liberatore, V., Farach-Colton, M., Kremer, U.: Evaluation of algorithms for local register allocation. In: Jähnichen, S. (ed.) CC 1999 and ETAPS 1999. LNCS, vol. 1575, pp. 137–152. Springer, Heidelberg (1999)
Lueh, G.-Y., Gross, T., Adl-Tabatabai, A.-R.: Fusion-based register allocation. ACM Transactions on Programming Languages and Systems 22(3), 431–470 (2000)
Park, J., Moon, S.-M.: Optimistic register coalescing. In: Proceedings of PACT’98, pp. 196–204. IEEE Computer Society Press, Los Alamitos (1998)
Pereira, F.M.Q., Palsberg, J.: Register allocation via coloring of chordal graphs. In: Yi, K. (ed.) APLAS 2005. LNCS, vol. 3780, pp. 315–329. Springer, Heidelberg (2005)
Pereira, F.M.Q., Palsberg, J.: Register allocation after classical SSA elimination is NP-complete. In: Aceto, L., Ingólfsdóttir, A. (eds.) FOSSACS 2006 and ETAPS 2006. LNCS, vol. 3921, Springer, Heidelberg (2006)
Rastello, F., de Ferrière, F., Guillon, C.: Optimizing translation out of SSA using renaming constraints. In: Proceedings of CGO’04, pp. 265–278. IEEE Computer Society Press, Los Alamitos (2004)
Sreedhar, V.C., et al.: Translating out of static single assignment form. In: Cortesi, A., Filé, G. (eds.) SAS 1999. LNCS, vol. 1694, pp. 194–210. Springer, Heidelberg (1999)
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 2007 Springer Berlin Heidelberg
About this paper
Cite this paper
Bouchez, F., Darte, A., Guillon, C., Rastello, F. (2007). Register Allocation: What Does the NP-Completeness Proof of Chaitin et al. Really Prove? Or Revisiting Register Allocation: Why and How. In: Almási, G., Caşcaval, C., Wu, P. (eds) Languages and Compilers for Parallel Computing. LCPC 2006. Lecture Notes in Computer Science, vol 4382. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-72521-3_21
Download citation
DOI: https://doi.org/10.1007/978-3-540-72521-3_21
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-72520-6
Online ISBN: 978-3-540-72521-3
eBook Packages: Computer ScienceComputer Science (R0)