Wikipedia aboutSSAThe definition of is as follows:

In compiler design, static single assignment form (often abbreviated as SSA form or simply SSA) is a property of an intermediate representation (IR), which requires that each variable be assigned exactly once, and every variable be defined before it is used.
Existing variables in the original IR are split into versions, new variables typically indicated by the original name with a subscript in textbooks, so that every definition gets its own version. In SSA form, use-def chains are explicit and each contains a single element.

A concept in compiler design, which is the abbreviation of static single assignment paradigm and an attribute of intermediate expression IR. This attribute requires that each variable can only be assigned once and must be assigned before use. The concept of “assignment” is a concept in the compiler field and “definition”. Therefore, for various variables in real programming language, if there are multiple assignments and multiple references to different assignments, each referenced assignment will generate a new variable (for convenience of memory, the new variable can be named by adding subscript to the old variable name), The previous assignment without reference after assignment or without reference statement between multiple assignments will be automatically optimized by the compiler.

In the calculation diagram (commonly known as DAG,Directed Acyclic GraphIn directed acyclic graph), each node needs to be defined before use, that is, the life cycle of each node is a def use process. However, the relationship between nodes is that each node first uses the values of other nodes, then generates its own definition, and provides its own definition to the next node for use. The relationship between use def use.

For example, the following code is from C:

1 x=1;
2 y=2;
3 x=y+1;
4 z=x*y;
5 a=z+1;

During the first round of conversion, it becomes the following code:

1 x1=1;
2 y1=2;
3 x2=y1+1;
4 z1=x2*y1;
5 a1=z1+1;

According to the principle of SSA, X1 is not used after assignment, so it is useless code. Finally, the code optimized according to SSA specification is:

1 y1=2;
2 x2=y1+1;
3 z1=x2*y1;
4 a1=z1+1;



Moreover, it is obvious that x2 and Y1 are the last reference in the third line. After executing x2 and Y1 in the third line, the resources can be released.