Explain optimizing transformations?
Optimizing transformations:
It is a rule for rewriting a segment of a program to enhance its execution efficiency without influencing its meaning. Usually used optimizing transformations are given below:
(a) Compile time evaluation: Execution efficiency can be enhanced by performing certain action given in a program through compilation itself. Constant folding is the important optimization of this type. While all operands in an operation are constants, the operation can be performed on compilation time.
For illustration: a: =3.141557/2 can be replaced through a:=1.570785 removing a division operation.
(b) Elimination of common subexpressions:
Common subexpressions are occurrences of expressions yielding similar value. For illustration: a:=b*c t: = b*c
λ: = b*c + 5.2 => a: = t
λ: = t + 5.2
(c) Dead code elimination: Code that can be omitted from a program without influencing its results is termed as dead code. For illustration: An assignment statement x: = < exp > constitutes dead code if the value assigned to x is not utilized in the program.
(d)Frequency and strength reduction:
Execution time of a program can be reduced through moving code from a part of programs that is executed very frequently to the other part of the program that is executed fewer times.
The strength reduction replaces the occurrence of a time consuming operation through an occurrence of a faster operation.