GATE / CS ARCHIVE

GATE CSE 2021 SET 2 / QUESTION 38

GATE CSE 2021 Set 2 Q38

Compiler Design · Code Optimization & Data-Flow Analysis · Full GATE CSE 2021 Set 2 paper

GATE 2021 Set 2, Q38 2 marks · MCQ
Report issue

Code Optimization & Data-Flow Analysis

Question 38, GATE 2021: USE(S) means variables used in S; IN(S),OUT(S) are live variables on entry/exit. Basic block is S1 followed by S2. A OUT(S1)=IN(S2); B OUT(S1)=IN(S1)∪USE(S1); C OUT(S1)=IN(S2)∪OUT(S2); D OUT(S1)=USE(S1)∪IN(S2).
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Inside a basic block S1 has S2 as its unique immediate successor. Values live just after S1 are exactly those live just before S2, so OUT(S1)=IN(S2), A. Uses at S1 do not automatically remain live afterward, and a definition in S2 can kill a value that is live after S2.

The general equations are OUT(S)=union of IN of immediate successors, and IN(S)=USE(S)∪(OUT(S)−DEF(S)). A basic block has no branch between S1 and S2, reducing the first equation to A. For example S1 reads x then S2 overwrites x: x can be used at S1 without needing to remain live after it, refuting formulas that force USE(S1) into OUT(S1).

Original paper, page 77 · Answer key