Describe local and global optimization.

Local optimization:

The local optimization is performed within a straight-line or a basic block of code without information from any other block. The different local optimizations that can be applied to a block (or procedure) are

1 Constant folding. i.e., replacing the run-time computations by the compile computations.

2 Common subexpression elimination, i.e., if the value resulting from the calculation of a subexpression is used multiple times, perform the calculation once and substitute the result for each individual calculation.

For example,

A:=B+C+D
E:=B+C+F
is transformed to
T1:=B+D
A1:=T1+D
E:=T1+F

Global optimization

The local optimization involves the statements within a sil4e block (or basic block). All other optimizations are called global optimizations- The global optimization allows the compiler/optimizer to look at the overall program and determine how best to apply the desired optimization leveL The global optimization is generally performed by using data flow analysis the transmission of used relationships from all parts of the program to the places where the information can be of use.

Leave a Reply