Skip to content
Official PYQ · 2025

GATE CS 2025 Set 1 Q3 — Local Optimization

Explain with AI

Which ONE of the following techniques used in compiler code optimization uses live variable analysis?

Choose one option
View worked solution

Answer: B

Live Variable Analysis (LVA) is a backward data-flow analysis technique used to determine, at each point in a program, which variables may be read in the future before being redefined (i.e., which variables are "live").

Let's analyze the given options to see which technique utilizes this analysis:

  • Register assignment to variables (Option B): To allocate a limited number of physical registers to program variables, the compiler must determine which variables are active simultaneously. If two variables are never live at the same time, they can share the same register. This is solved using register allocation via graph-coloring, where the interference graph is constructed directly from the live ranges of variables obtained via Live Variable Analysis. Thus, this is the correct option.
  • Run-time function call management (Option A): This is a run-time mechanism managed by the activation stack (stack frames) for handling function calls, parameters, and local variables. It is not a static optimization technique that uses live variable analysis.
  • Strength reduction (Option C): This optimization replaces computationally expensive operations with cheaper ones (e.g., replacing x×2x \times 2 with x+xx + x, or optimizing induction variables in loops). It does not require live variable analysis.
  • Constant folding (Option D): This is the compile-time evaluation of expressions with constant operands (e.g., replacing 3×53 \times 5 with 1515). It does not depend on live variable analysis.

Therefore, Register assignment to variables is the correct technique that uses live variable analysis.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Local Optimization questions