Home › Previous year questions › GATE 2010 CS (CS1) › Question 47GATE 2010 CS (CS1) – Question 47 Compiler Design · Code Optimization and Data Flow Analysis · 2 marks · Multiple choice
Without spilling values to memory, what is the minimum number of registers needed for this basic block?
a=1
b=10
c=20
d=a+b
e=c+d
f=c+e
b=c+e
e=b+f
d=5+e
return d+f2 3 4 6 Practise this question in The GATE Grind →
Show answer and explanation Correct answer: (B) 3
Explanation Immediately after computing f, the values c,e,f are simultaneously needed: c and e for the next assignment, and f for later uses. Thus at least three registers are required. Three suffice by reusing registers of dead a,b,d values, overwriting c when computing the later b, and overwriting dead operands thereafter. Hence B.
More Code Optimization and Data Flow Analysis questions GATE 2015 CS (CS2) Q27 – Match P: lexical analysis; Q: parsing; R: register allocation; S: expression evaluation.… GATE 2021 CS (CS2) Q40 – Apply common-subexpression elimination to the code. y points to a heap struct with f1,f2;… GATE 2021 CS (CS2) Q48 – For statement S, USE(S) contains variables used in S; IN(S) those live at entry; OUT(S)… GATE 2026 CS (CS1) Q42 – Consider the control flow graph shown in the figure. Which one of the following options… GATE 2026 CS (CS2) Q45 – Consider the control flow graph given below. Which one of the following options is the set… GATE 2025 CS (CS1) Q13 – Which ONE of the following techniques used in compiler code optimization uses live… All Code Optimization and Data Flow Analysis questions →