The GATE Grind

GATE 2021 CS (CS2) – Question 48

Compiler Design · Code Optimization and Data Flow Analysis · 2 marks · Multiple choice

For statement S, USE(S) contains variables used in S; IN(S) those live at entry; OUT(S) those live at exit. A basic block consists of S1 immediately followed by S2. Which equation is correct?

  1. OUT(S1)=IN(S2)
  2. OUT(S1)=IN(S1)∪USE(S1)
  3. OUT(S1)=IN(S2)∪OUT(S2)
  4. OUT(S1)=USE(S1)∪IN(S2)

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) OUT(S1)=IN(S2)

Explanation

There is no intervening instruction or alternative successor between the two statements. A value live immediately after S1 is exactly a value live immediately before S2. Hence OUT(S1)=IN(S2), A. Variables used inside S1 need not remain live after it.

More Code Optimization and Data Flow Analysis questions

All Code Optimization and Data Flow Analysis questions →