GATE CS 2015, set 1 · Question 46 · Compiler Design · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer

A variable x is said to be live at a statement Sᵢ in a program if the following three conditions hold simultaneously:
i. There exists a statement Sⱼ that uses x
ii. There is a path from Sᵢ to Sⱼ in the flow graph corresponding to the program
iii. The path has no intervening assignment to x including at Sᵢ and Sⱼ
The variables which are live both at the statement in basic block 2 and at the statement in basic block 3 of the above control flow graph are

Control flow graph with four basic blocks. Block 1 (top) contains three statements: p = q + r; s = p + q; u = s * v. Block 2 (middle left) contains: v = r + u. Block 3 (middle right) contains: q = s * u. Block 4 (bottom) contains: q = v + r. Directed edges: block 1 to block 2, block 1 to block 3, block 2 to block 4, block 3 to block 4, and a curved back edge from block 4 to block 1.
  1. (A) p, s, u
  2. (B) r, s, u
  3. (C) r, u
  4. (D) q, v
Answer

Answer (C)

Answer from the official GATE CS 2015 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes