Constant folding
lastmod 2016-12-01created 2016-12-011 edits
Constant folding and constant propagation are related compiler optimizations used by many modern compilers. An advanced form of constant propagation known as sparse conditional constant propagation can more accurately propagate constants and simultaneously remove dead code.
Constant propagation is a compiler optimization technique: if the value of a variable is known to be a constant at compile time, the constant is used directly in place of the variable. If this makes an entire expression constant, it can be computed at compile time and the result used directly. (constant folding)
Example
Constant Propagation is a very simple (in the principle) optimization left to compilers.
The program is thus equivalent to: