A Functional Perspective on SSA Optimisation Algorithms

Abstract The static single assignment (SSA) form is central to a range of optimisation algorithms relying on data flow information, and hence, to the correctness of compilers employing those algorithms. It is well known that the SSA form is closely related to lambda terms (i.e., functional programs), and, considering the large amount of energy expended on theories and frameworks for formal reasoning in the lambda calculus, it seems only natural to leverage this connection to improve our capabilities to reason about compiler optimisations. In this paper, we discuss a new formalisation of the mapping from SSA programs to a restricted form of lambda terms, called administrative normal form (ANF). We conjecture that this connection improves our ability to reason about SSA-based optimisation algorithms and provide a first data point by presenting an ANF variant of a well known SSA-based conditional constant propagation algorithm.

[1]  Bowen Alpern,et al.  Detecting equality of variables in programs , 1988, POPL '88.

[2]  Mark N. Wegman,et al.  Constant propagation with conditional branches , 1985, POPL.

[3]  Fred B. Schneider,et al.  A Language-Based Approach to Security , 2001, Informatics.

[4]  Mark N. Wegman,et al.  Efficiently computing static single assignment form and the control dependence graph , 1991, TOPL.

[5]  Simon L. Peyton Jones,et al.  Imperative functional programming , 1993, POPL '93.

[6]  Andrew W. Appel,et al.  SSA is functional programming , 1998, SIGP.

[7]  S. Jones,et al.  A Transformation-Based Optimiser for Haskell , 1998, Sci. Comput. Program..

[8]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

[9]  Andrew Tolmach An External Representation for the GHC Core Language , 2001 .

[10]  Arthur B. Maccabe,et al.  The program dependence web: a representation supporting control-, data-, and demand-driven interpretation of imperative languages , 1990, PLDI '90.

[11]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.

[12]  Richard A. Kelsey A correspondence between continuation passing style and static single assignment form , 1995 .

[13]  Karl Crary,et al.  From system F to typed assembly language , 1999 .

[14]  Ralf Hinze,et al.  Haskell 98 — A Non−strict‚ Purely Functional Language , 1999 .

[15]  Sorin Lerner,et al.  Composing dataflow analyses and transformations , 2002, POPL '02.

[16]  Patrick Cousot,et al.  Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints , 1977, POPL.

[17]  Peter Lee,et al.  TIL: a type-directed, optimizing compiler for ML , 2004, SIGP.

[18]  Olin Shivers,et al.  Control flow analysis in scheme , 1988, PLDI '88.

[19]  Amr Sabry,et al.  The essence of compiling with continuations , 1993, PLDI '93.

[20]  Simon L. Peyton Jones,et al.  Compiling Haskell by Program Transformation: A Report from the Trenches , 1996, ESOP.

[21]  Thomas Johnsson,et al.  Lambda Lifting: Treansforming Programs to Recursive Equations , 1985, FPCA.

[22]  Andrew W. Appel,et al.  Modern Compiler Implementation in ML , 1997 .

[23]  Amr Sabry,et al.  Is continuation-passing useful for data flow analysis? , 1994, PLDI '94.