The following program was given:
module Test([4]int ?a, int ?b, int !c) {
int t,x,y;
t = b;
x = 0;
y = 0;
pause;
for(i=0..3) {
next(x) = y * t;
pause;
next(y) = x + a[i];
pause;
}
c = y;
}
The for-loop is thereby an abbreviation of a sequence of its body statements. If we unroll that for-loop, we get the following program:
module Test([4]int ?a, int ?b, int !c) {
int t,x,y;
t = b;
x = 0;
y = 0;
pause;
next(x) = y * t;
pause;
next(y) = x + a[0];
pause;
next(x) = y * t;
pause;
next(y) = x + a[1];
pause;
next(x) = y * t;
pause;
next(y) = x + a[2];
pause;
next(x) = y * t;
pause;
next(y) = x + a[3];
pause;
c = y;
}
In the above version, it is better seen that there are many assignments to the same variables x and y. We have to introduce fresh instances for each assignment to ensure a SSA form, and therefore get the following program:
module Test([4]int ?a, int ?b, int !c) {
int t,x,x1,x2,x3,x4,y,y1,y2,y3,y4;
t = b;
x = 0;
y = 0;
pause;
next(x1) = y * t;
pause;
next(y1) = x + a[0];
pause;
next(x2) = y1 * t;
pause;
next(y2) = x1 + a[1];
pause;
next(x3) = y2 * t;
pause;
next(y3) = x2 + a[2];
pause;
next(x4) = y3 * t;
pause;
next(y4) = x3 + a[3];
pause;
c = y4;
}
The above program is the SSA form that is required for a further mapping to a combinational circuit or a systolic array if the latter should be executed in a pipelined fashion. Note that for SSA form, it is no problem to read a variable more than once, but there should only be one assignment to each variable.