3. OPTIMIZATION OF BASIC BLOCKS
There are two types of basic block optimizations.
They are :
Structure -Preserving Transformations
Algebraic Transformations
.1 Structure- Preserving Transformations:
The primary Structure-Preserving Transformation on basic blocks are: � Common sub-expression elimination
3.2 Common sub-expression elimination:
Common sub expressions need not be computed over and over again. Instead they can be computed once and kept in store from where it’s referenced when encountered again – of course providing the variable values in the expression still remain constant.
Example:
a: =b+c
b: =a-d
c: =b+c
d: =a-d
The 2nd and 4th statements compute the same expression: b+c and a-d
Basic block can be transformed to
a: =b+c
b: =a-d
c: =a
d: =b
3.3 Dead code elimination:
It’s possible that a large amount of dead (useless) code may exist in the program. This might be especially caused when introducing variables and procedures as part of construction or error -correction of a program – once declared and defined, one forgets to remove them in case they serve no purpose. Eliminating these will definitely optimize the code. 3.4 Renaming of temporary variables:
3.5 Interchange of two independent adjacent statements:
Two statements
t1:=b+c
t2:=x+y
can be interchanged or reordered in its computation in the basic block when value of t1 does not affect the value of t2.
3.6 Algebraic Transformations:
a :=b+c e :=c+d+b
the following intermediate code may be generated:
a :=b+c t :=c+d
e :=t+b
26 videos|66 docs|30 tests
|
1. What is the concept of optimization of basic blocks in computer science engineering? |
2. How can optimization of basic blocks benefit computer science engineering? |
3. What techniques are commonly used for optimizing basic blocks in computer science engineering? |
4. How does optimization of basic blocks impact the performance of a computer program? |
5. Are there any limitations or trade-offs associated with the optimization of basic blocks in computer science engineering? |
|
Explore Courses for Computer Science Engineering (CSE) exam
|