The routine optimizer.aliasRemoval() walks through the program
looking for simple assignment statements, like V:=W. It replaces all
subsequent occurrences of V by W, provided V is assigned a value
once and W does not change in the remainder of the code. Special
care should be taken for iterator blocks as illustrated in the case
below:
i:=0;
b:= "done";
barrier go:= true;
c:=i+1;
d:="step";
v:=d;
io.print(v);
i:=c;
redo go:= i<2;
exit go;
io.print(b);
optimizer.aliasRemoval();
The constant strings are propagated to the print() routine, while
the initial assigment i:=0 should be retained. The code block becomes:
i:=0;
barrier go:= true;
c:=i+1;
io.print("step");
i:=c;
redo go:= i<2;
exit go;
io.print("done");
A special case is backward propagation of constants. The following snippet is the result of the JITO emptyset. It can be further reduced to avoid useless assignments.
_53 := sql.bind("sys","_tables","type",0);
(_54,_56,_58,_60) := bat.partition(_53);
_53 := nil;
_67 := _54;
_54 := nil;
_75 := _67;
_67 := nil;
_83 := _75;
_75 := nil;