Static single-assignment form

This is an old revision of this page, as edited by Dcoetzee (talk | contribs) at 00:58, 23 November 2003 (Oops error in example). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In compilers, static single assignment form, more often abbreviated SSA form or just SSA, is an intermediate representation in which every variable is assigned exactly once. Existing variables in the original IR are split into versions, new variables typically indicated by the original name with a subscript, so that every definition gets its own version. In SSA form, use-def chains are explicit and each contain a single element.

SSA was developed by researchers at IBM in the 80's.

Benefits of SSA

The primary usefulness of SSA comes from how it simultaneously simplifies and improves the results of a variety of optimizations, by simplifying the properties of variables. For example, consider this piece of code:

y := 1
y := 2
x := y

As humans, we can see that the first assignment isn't necessary, and that the value of y being used in the third line comes from the second assignment of y. A program would have to perform reaching definition analysis to determine this. But if the program is in SSA form, both of these are immediate:

y1 := 1
y2 := 2
x1 := y2

Algorithms which are either permitted or strongly enhanced by the use of SSA include:

Converting to SSA

More needed here describing need for phi functions, the dominance-frontier based algorithm for computing "minimal" SSA, and other things.

See also: Compiler optimization