Which ONE of the following techniques used in compiler code optimization uses…

2025

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

Answer: B. Register assignment to variablesCorrect answer: Register assignment to variables (register allocation). Why: Live variable analysis is a backward data-flow analysis that computes, at each…

  1. A.

    Run-time function call management

  2. B.

    Register assignment to variables

  3. C.

    Strength reduction

  4. D.

    Constant folding

Attempted by 212 students.

Show answer & explanation

Correct answer: B

Correct answer: Register assignment to variables (register allocation).

Why: Live variable analysis is a backward data-flow analysis that computes, at each program point, which variables may be used in the future (the live-in and live-out sets). It identifies the live ranges of variables, and that information is essential for register allocation.

  • Builds the interference graph: two variables that are live at the same time interfere and cannot share a register.

  • Guides spilling decisions: variables with large live ranges or high interference are candidates to be moved to memory.

  • Helps register coalescing and other allocation heuristics by revealing when variables do not overlap in time.

Notes on the other choices:

  • Run-time function call management deals with calling conventions, stack frames, and parameter passing; it is not driven by live variable analysis.

  • Strength reduction is a local arithmetic optimization (e.g., replacing multiplication with addition) and does not require liveness information.

  • Constant folding evaluates constant expressions at compile time and does not depend on live variable analysis.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…