Register allocation: what does the NP-completeness proof of Chaitin et al. really prove? or revisiting register allocation: why and how

  • Authors:
  • Florent Bouchez;Alain Darte;Christophe Guillon;Fabrice Rastello

  • Affiliations:
  • LIP, UMR, CNRS-ENS Lyon-UCB, Lyon-INRIA, France;LIP, UMR, CNRS-ENS Lyon-UCB, Lyon-INRIA, France;Compiler Group, ST, HPC, STS, Grenoble, France;LIP, UMR CNRS-ENS Lyon-UCB Lyon-INRIA, France

  • Venue:
  • LCPC'06 Proceedings of the 19th international conference on Languages and compilers for parallel computing
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

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.