Optimization of Basic Blocks:Optimization process can be applied on a basic block. While optimization, we don't need to change the set of expressions computed by the block. There are two type of basic block optimization. These are as follows:
1. Structure preserving transformations:The primary StructurePreserving Transformation on basic blocks is as follows:
(a) Common subexpression elimination:In the common subexpression, you don't need to be computed it over and over again. Instead of this you can compute it once and kept in store from where it's referenced when encountered again. In the above expression, the second and forth expression computed the same expression. So the block can be transformed as follows: (b) Deadcode elimination
(c) Renaming temporary variablesA statement t:= b + c can be changed to u:= b + c where t is a temporary variable and u is a new temporary variable. All the instance of t can be replaced with the u without changing the basic block value. (d) Interchange of statementSuppose a block has the following two adjacent statements: These two statements can be interchanged without affecting the value of block when value of t1 does not affect the value of t2. 2. Algebraic transformations:
The following intermediate code may be generated:
Next TopicMachine Independet
