In each basic block, I perform value numbering to do constant folding and local common sub-expression elimination in that block. The value of all variables that are detected to be constants are propagated locally for constant folding. Also, repeated use of the same expression is detected, and instead of performing the computation multiply, these values are stored in new pseudo-variables and are re-used.