----------------------------- a5ss Static Single Assignment ----------------------------- Now, we are going to take a look at the Static Single Assignment form that GCC uses later during optimization. In SSA form, each variable may be assigned at most once. Also, exactly one assignment of each variable dominates every use of the variable. In order to implement SSA, local variables are suffixed with a unique number which represents the assignment. For example, two assignments to the variable `a' may look like `a_0' and `a_1'. Compile the following program (file a5ss.c) and observe the GIMPLE dumps. Source file : a5ss.c Compilation : gcc -c -fdump-tree-cfg -fdump-tree-ssa a5ss.c View result : vi -O a5ss.c.*.cfg a5ss.c.*.ssa Clear dumps : rm -f a5ss.c.* a5ss.o Program (similar to the loops assignment) ------- int main() { int a, b, n, i; for(i=0; i < n; i++) { if(a > b) a = b + n; else a = b * n; }; } Questions --------- 1 Do you notice that each usage of local variable as an operand uses a suffix that can be tracked to it's assignment? Why do some variables have a suffix `(D)'? 2 Find the point in the CFG in which the paths of the two assignments to variable `a' ("a = b + n" and "a = b * n") merge. You will notice that a PHI statement is introduced. Can you guess the syntax of the PHI statement? 3 Can you think of an example in which a PHI node merges more than two versions of a variable?