Constant Propagation is a technique in which the compiler removes and replaces variables of a static constant value before run time, thus speeding up execution.
Given the source code
let a = 3;
let b = a + 5;
the compiler will essentially transform this into
let b = 3 + 5;
(And combined with Constant Folding (#34), it would reduce to let b = 8;.)
With constant propagation, the static fixed constant is removed all throughout the scope it’s in, and replaced by its value.
If the variable is unfixed however, this operation will not be performed, since its value could change.
let unfixed a = 3;
let b = a + 5;
a = 2;
% (no constant propagation here)
Constant Propagation is a technique in which the compiler removes and replaces variables of a static constant value before run time, thus speeding up execution.
Given the source code
the compiler will essentially transform this into
(And combined with Constant Folding (#34), it would reduce to
let b = 8;
.)With constant propagation, the static fixed constant is removed all throughout the scope it’s in, and replaced by its value.
If the variable is
unfixed
however, this operation will not be performed, since its value could change.