Skip to main content

Register Allocation: What Does the NP-Completeness Proof of Chaitin et al. Really Prove? Or Revisiting Register Allocation: Why and How

  • Conference paper
Languages and Compilers for Parallel Computing (LCPC 2006)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 4382))

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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)

    Google Scholar 

  2. Bouchez, F., et al.: Register allocation and spill complexity under SSA. Technical Report RR2005-33, LIP, ENS-Lyon, France, (Aug. 2005)

    Google Scholar 

  3. Bouchez, F., et al.: On the complexity of register coalescing. Technical Report RR2006-15, LIP, ENS-Lyon, France (Apr. 2006)

    Google Scholar 

  4. Briggs, P., Cooper, K., Torczon, L.: Improvements to graph coloring register allocation. ACM Transactions on Programming Languages and Systems 16(3), 428–455 (1994)

    Article  Google Scholar 

  5. 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)

    Article  Google Scholar 

  6. Brisk, P., et al.: Polynomial time graph coloring register allocation. In: 14th International Workshop on Logic and Synthesis, June (2005)

    Google Scholar 

  7. Budimlić, Z., et al.: Fast copy coalescing and live range identification. In: Proc. of PLDI’02, pp. 25–32. ACM Press, New York (2002)

    Google Scholar 

  8. Chaitin, G.J.: Register allocation & spilling via graph coloring. SIGPLAN Notices, Proceedings of Compiler Construction (CC’82) 17(6), 98–105 (1982)

    Article  MathSciNet  Google Scholar 

  9. Chaitin, G.J., et al.: Register allocation via coloring. Computer Languages 6, 47–57 (1981)

    Article  Google Scholar 

  10. 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)

    Chapter  Google Scholar 

  11. 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)

    Google Scholar 

  12. 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)

    Article  Google Scholar 

  13. Darte, A., Rastello, F.: Personal communication with Benoît Dupont de Dinechin, Jeanne Ferrante, and Christophe Guillon (2002)

    Google Scholar 

  14. Farach-Colton, M., Liberatore, V.: On local register allocation. Journal of Algorithms 37(1), 37–65 (2000)

    Article  MATH  MathSciNet  Google Scholar 

  15. 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)

    MATH  Google Scholar 

  16. Garey, M.R., et al.: The complexity of coloring circular arcs and chords. SIAM J. of Algebr. Discrete Methods 1(2), 216–227 (1980)

    Article  MATH  MathSciNet  Google Scholar 

  17. George, L., Appel, A.W.: Iterated register coalescing. ACM Transactions on Programming Languages and Systems 18(3), 300–324 (1996)

    Article  Google Scholar 

  18. Golumbic, M.C.: Algorithmic Graph Theory and Perfect Graphs. Academic Press, New York (1980)

    MATH  Google Scholar 

  19. 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)

    Chapter  Google Scholar 

  20. Knobe, K., Zadeck, K.: Register allocation using control trees. Technical Report No. CS-92-13, Brown University (1992)

    Google Scholar 

  21. Leung, A., George, L.: Static single assignment form for machine code. In: Proceedings of PLDI’99, pp. 204–214. ACM Press, New York (1999)

    Google Scholar 

  22. 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)

    Google Scholar 

  23. 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)

    Article  Google Scholar 

  24. Park, J., Moon, S.-M.: Optimistic register coalescing. In: Proceedings of PACT’98, pp. 196–204. IEEE Computer Society Press, Los Alamitos (1998)

    Google Scholar 

  25. 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)

    Chapter  Google Scholar 

  26. 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)

    Chapter  Google Scholar 

  27. 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)

    Google Scholar 

  28. 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)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

George Almási Călin Caşcaval Peng Wu

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics