Compiler Design and Construction - Old Questions
10. Define the following optimization techniques:
a.
Unreachable code elimination
b.
Flow-of-control optimization
a. Unreachable code elimination
The unreachable code is a part of the source code that will never be executed due to inappropriate exit points/control flow.. By eliminating these useless things from a code, the code will get optimized. For e.g.
b. Flow-of-control optimization
An unlabeled instruction immediately following an unconditional jump can be removed. For e.g.
Using peephole optimization unnecessary jumps can eliminate in either the intermediate code or the target code.
Goto L1
. . . . . . .
L1: goto L2
By the sequence,
Goto L2
. . . . . . .
L1: goto L2
If there are no jumps to L1 then it may be possible to eliminate the statement L1: goto L2 provided it preceded by an unconditional jump.