Match the optimization technique in List-I with its appropriate classification…

Match the optimization technique in List-I with its appropriate classification in List-II.

image.png

Answer: A. P-3, Q-2, R-1, S-4Correct matching: P-3, Q-2, R-1, S-4 P) Constant folding: Evaluating expressions with only constants at compile time (for example, replacing x = 2 * 100 with…

  1. A.

    P-3, Q-2, R-1, S-4

  2. B.

    P-1, Q-2, R-4, S-3

  3. C.

    P-3, Q-4, R-1, S-2

  4. D.

    P-4, Q-1, R-3, S-2

Attempted by 61 students.

Show answer & explanation

Correct answer: A

Correct matching: P-3, Q-2, R-1, S-4

  • P) Constant folding: Evaluating expressions with only constants at compile time (for example, replacing x = 2 * 100 with x = 200). This is performed within basic blocks and does not depend on target-machine details, so it is a machine-independent, local optimization.

  • Q) Strength reduction: Replacing expensive operations inside loops with cheaper ones (for example, converting multiplication in a loop into repeated addition). It targets loop bodies and is independent of the machine, so it is a machine-independent, loop optimization.

  • R) Register allocation: Deciding which variables are kept in CPU registers depends on the target architecture (number and types of registers, calling conventions, etc.). Because it relies on machine-specific details, it is a machine-dependent optimization.

  • S) Dead code elimination: Removing instructions or code paths whose results are never used or are unreachable. This typically requires data-flow analysis across basic blocks or entire functions, so it is a machine-independent, global optimization.

Therefore the correct mapping is: P → machine-independent, local; Q → machine-independent, loop; R → machine-dependent; S → machine-independent, global.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…