

Compiling with Continuations, Continued (2007) [pdf] - chicken_lady
http://research.microsoft.com/en-us/um/people/akenn/sml/CompilingWithContinuationsContinued.pdf

======
nanofortnight
CPS is formally equivalent to SSA, is it not? What are advantages of using CPS
over SSA?

~~~
gsg
See
[http://mlton.org/pipermail/mlton/2003-January/023054.html](http://mlton.org/pipermail/mlton/2003-January/023054.html)
for an in-depth comparison from a compiler hacker experienced with both styles
of IR.

A summary is that there is no advantage to CPS, since it is SSA with a scope
nesting requirement that gets in the way of some beneficial transformations.

~~~
l_dopa
This is an area where the compiler and programming language communities often
seem to be talking past each other. In the post you linked, Weeks is talking
about CPS and SSA as the datastructures manipulated by optimization
algorithms. CPS is interesting primarily as a language in the formal sense of
assigning semantics to programs. Whether you choose to represent those
programs naively as a tree structure or with an efficient graph representation
as in SSA, you're still using CPS.

This paper is really good because, unlike a lot of compiler literature, it
treats both semantics and term representation.

~~~
gsg
Although I take your point about CPS in other disciplines, TFA advocates
_compiling_ with continuations. A criticism of its suitability for compilation
would seem to be relevant.

~~~
l_dopa
Sure, and Weeks is totally correct regarding tree vs. flat representations,
but I think identifying CPS with the former and SSA with the latter is
misleading. The scoping discipline (respectively, dominator tree) is part of
the language whether you represent it as subtrees or leave it implicit.

It would be more accurate to say that SSA is a particularly efficient data
structure for representing a subset of CPS terms.

