Peephole optimization is form of
(A) Loop optimization
(B) Local optimization
(C) Constant folding
(D) Data flow analysis
Explanation: In the optimisation technique, we optimise the code during compilation which reduces the space complexity as well as time complexity and eliminate the redundant code.Peephole optimization one of the optimisation technique which performed on a small set of compiler-generated instructions and the small set is known as the peephole or window. Peephole optimization does change the small set of instructions to the other an equivalent set which has better performance.:-
For example :-
- Peephole optimization technique would remove both instructions push and pop operation on stack instead of pushing register A onto the stack and then immediately popping the value back into register A
- Peephole optimization technique might do an arithmetic shift left Instead of adding A to A.
- Peephole optimization technique might scale the floating point register’s exponent by 3 Instead of multiplying a floating point register by 8.
The main objective of peephole optimization is:
- To improve performance
- To reduce memory footprint
- To reduce code size
Option (B) is correct.
Quiz of this Question