Primary structure-preserving transformations on basic blocks-
- Common sub-expression elimination
- Dead-code elimination
- Renaming of temporary variable
- Interchanging of two independent-adjacent statements.
Common sub-expression elimination: Consider the basic block-
a : = b+c c : = b+c
b : = a-d d : = a-d
The 2nd and fourth statements compute same expression namely b + c - d. So, the transform basic block is as-
a : = b+c c : = b+c
b : = a-d d : = bDead-Code Elimination : Let us a variable x is dead, that is, never subsequently used. at the point where the statement x : = y + z appears in a basic block. Then this statement may be safely removed without changing the value of the basic block.
Renaming of temporary variable: Let us a statement t : = a+b where t is a temporary. If we change this statement t to u, then the value of basic block is not changed.
Interchange of statement: Let us consider the two adjacent statements-
t1 : = x+y
t2 : = a+b
We can interchange the two statement without effecting the value of the block if neithern a nor b is t1 & neither x nor y is t2.
0 comments:
Post a Comment