Talk:Constant folding

From Wikipedia, the free encyclopedia

The below article appears to be more correct, so I'm moving it here.

Constant folding is the optimization done by compilers in early stage of the compilation of a program. In C it is the optimization that makes it possible to have constant expressions in array-declarations, like:


#define WIDTH 320
#define HEIGHT 240
char buffer[WIDTH*HEIGHT];


Constant folding is similar to constant propagation, however constant folding must be done before the high-level language is translated to three-address-code to make code like above work. Constant propagation is done on the three-address-code (preferably on SSA form)