Register Allocation After Classical SSA Elimination is NP-Complete

  • Fernando Magno Quintão Pereira
  • Jens Palsberg
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3921)


Chaitin proved that register allocation is equivalent to graph coloring and hence NP-complete. Recently, Bouchez, Brisk, and Hack have proved independently that the interference graph of a program in static single assignment (SSA) form is chordal and therefore colorable in linear time. Can we use the result of Bouchez et al. to do register allocation in polynomial time by first transforming the program to SSA form, then performing register allocation, and finally doing the classical SSA elimination that replaces φ-functions with copy instructions? In this paper we show that the answer is no, unless P = NP: register allocation after classical SSA elimination is NP-complete. Chaitin’s proof technique does not work for programs after classical SSA elimination; instead we use a reduction from the graph coloring problem for circular arc graphs.


Interval Graph Chordal Graph Register Allocation Graph Coloring Problem Interference Graph 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Appel, A.W., Palsberg, J.: Modern Compiler Implementation in Java, 2nd edn. Cambridge University Press, Cambridge (2002)CrossRefGoogle Scholar
  2. 2.
    Biró, M., Hujter, M.: Precoloring extension. I: interval graphs. In: Discrete Mathematics, pp. 267–279. ACM Press, New York (1992); Special volume (part 1) to mark the centennial of Julius Petersen’s “Die theorie der regularen graphs”Google Scholar
  3. 3.
    Bodlaender, H., Gustedt, J., Telle, J.A.: Linear-time register allocation for a fixed number of registers. In: SIAM Symposium on Discrete Algorithms, pp. 574–583 (1998)Google Scholar
  4. 4.
    Bouchez, F.: Allocation de registres et vidage en mémoire. Master’s thesis, ENS Lyon (2005)Google Scholar
  5. 5.
    Briggs, P., Cooper, K.D., Harvey, T.J., Simpson, L.T.: Practical improvements to the construction and destruction of static single assignment form. Software Practice and Experience 28(8), 859–881 (1998)CrossRefGoogle Scholar
  6. 6.
    Brisk, P., Dabiri, F., Macbeth, J., Sarrafzadeh, M.: Polynomial-time graph coloring register allocation. In: 14th International Workshop on Logic and Synthesis, ACM Press, New York (2005)Google Scholar
  7. 7.
    Budimlic, Z., Cooper, K.D., Harvey, T.J., Kennedy, K., Oberg, T.S., Reeves, S.W.: Fast copy coalescing and live-range identification. In: International Conference on Programming Languages Design and Implementation, pp. 25–32. ACM Press, New York (2002)Google Scholar
  8. 8.
    Chaitin, G.J., Auslander, M.A., Chandra, A.K., Cocke, J., Hopkins, M.E., Markstein, P.W.: Register allocation via coloring. Computer Languages 6, 47–57 (1981)CrossRefGoogle Scholar
  9. 9.
    Cytron, R., Ferrante, J., Rosen, B.K., Wegman, M.N., Zadeck, F.K.: Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems 13(4), 451–490 (1991)CrossRefGoogle Scholar
  10. 10.
    de Ferriére, F., Guillon, C., Rastello, F.: Optimizing the translation out-of-SSA with renaming constraints. ST Journal of Research Processor Architecture and Compilation for Embedded Systems 1(2), 81–96 (2004)Google Scholar
  11. 11.
    Farach, M., Liberatore, V.: On local register allocation. In: 9th ACM-SIAM symposium on Discrete Algorithms, pp. 564–573. ACM Press, New York (1998)Google Scholar
  12. 12.
    Garey, M.R., Johnson, D.S., Miller, G.L., Papadimitriou, C.H.: The complexity of coloring circular arcs and chords. SIAM J. Algebraic Discrete Methods 1(2), 216–227 (1980)MathSciNetCrossRefMATHGoogle Scholar
  13. 13.
    Garey, M.R., Johnson, D.S., Stockmeyer, L.: Some simplified NP-complete problems. Theoretical Computer Science 1(3), 193–267 (1976)MathSciNetCrossRefMATHGoogle Scholar
  14. 14.
    Gavril, F.: Algorithms for minimum coloring, maximum clique, minimum covering by cliques, and maximum independent set of a chordal graph. SICOMP 1(2), 180–187 (1972)MathSciNetCrossRefMATHGoogle Scholar
  15. 15.
    Gavril, F.: The intersection graphs of subtrees of a tree are exactly the chordal graphs. Journal of Combinatoric B(16), 46–56 (1974)MATHGoogle Scholar
  16. 16.
    Hack, S.: Interference graphs of programs in SSA-form. Technical Report ISSN 1432-7864, Universitat Karlsruhe (2005)Google Scholar
  17. 17.
    Hack, S., Grund, D., Goos, G.: Register allocation for programs in SSA-form. In: 15th International Conference on Compiler Construction, Springer, Heidelberg (2006)Google Scholar
  18. 18.
    Leung, A., George, L.: Static single assignment form for machine code. In: Conference on Programming Language Design and Implementation, pp. 204–214. ACM Press, New York (1999)Google Scholar
  19. 19.
    Marx, D.: A short proof of the NP-completeness of circular arc coloring (2003)Google Scholar
  20. 20.
    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)CrossRefGoogle Scholar
  21. 21.
    Rosen, B.K., Zadeck, F.K., Wegman, M.N.: Global value numbers and redundant computations. In: ACM SIGPLAN-SIGACT symposium on Principles of Programming languages, pp. 12–27. ACM Press, New York (1988)CrossRefGoogle Scholar
  22. 22.
    Sethi, R.: Complete register allocation problems. In: 5th annual ACM symposium on Theory of computing, pp. 182–195. ACM Press, New York (1973)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Fernando Magno Quintão Pereira
    • 1
  • Jens Palsberg
    • 1
  1. 1.UCLAUniversity of CaliforniaLos AngelesUSA

Personalised recommendations