Regarding the code optimization, choose the correct sequence A. Algebraic Simplification B. Use of machine idioms C. Redundant - instruction elimination D. Flow of control optimization E. Improved target code Choose the correct answer from the options given below:
C, D, A, B, E
Peephole optimization (Aho, Lam, Sethi and Ullman, section on peephole optimization) examines a short sliding window of target instructions and replaces it with a shorter or faster sequence. The textbook presents its characteristic transformations in this order, and their combined result is improved target code.
1. Redundant-instruction elimination (C) — e.g. removing a LD that reloads a value just stored by ST, and deleting unreachable code.
2. Flow-of-control optimization (D) — replacing jumps to jumps (goto L1; L1: goto L2) by a direct jump to L2.
3. Algebraic simplification (A) — deleting x = x + 0 or x = x * 1 and applying strength reduction such as x2 → x*x.
4. Use of machine idioms (B) — using special instructions such as auto-increment addressing or INC instead of a general add.
5. The outcome is improved target code (E).
So the sequence is C, D, A, B, E. The other orders start with algebraic simplification, machine idioms or flow-of-control optimization and do not follow this progression.
C, D, A, B, E option is correct.