The GATE Grind

GATE Compiler Design: Intermediate Code Generation – Previous Year Questions

15 GATE previous year questions on Intermediate Code Generation (Compiler Design, Computer Science) with answers and explanations, from every paper.

15 questions worth 23 marks in all (7 1-mark, 8 2-mark). Asked between 2007 and 2025, so you can see how the topic has been tested over time.

  1. GATE 2007 CS Q54 (2 marks, Multiple choice) – A simplified computer has2 registers. OP Rj, Ri computes Rj OP Ri into Ri; OP m, Ri computes memory[m] OP Ri into Ri. OP is ADD/SUB. MOV m, Ri loads…
  2. GATE 2021 CS (CS2) Q23 (1 mark, Multiple select) – Which are NOT intermediate representations of a source program?
  3. GATE 2015 CS (CS2) Q28 (1 mark, Multiple choice) – Which statement about abstract syntax trees (ASTs) and control-flow graphs (CFGs) is true?
  4. GATE 2015 CS (CS2) Q44 (2 marks, Multiple choice) – Find the numbers of basic-block nodes and edges in the control-flow graph for:
  5. GATE 2014 CS (CS3) Q27 (1 mark, Multiple choice) – One purpose of intermediate code in compilers is to .
  6. GATE 2014 CS (CS2) Q44 (2 marks, Multiple choice) – A compiler generates this for C access X[i][j][k], with 32-bit int and 8-bit char: t0 = i * 1024 t1 = j * 32 t2 = k * 4 t3 = t1 + t0 t4 = t3 + t2 t5 =…
  7. GATE 2017 CS (CS1) Q22 (1 mark, Multiple choice) – Consider the following intermediate program in three address code Which one of the following corresponds to a *static single assignment* form of the…
  8. GATE 2017 CS (CS1) Q62 (2 marks, Numerical answer) – Consider the expression (a - 1) * (((b + c) / 3) + d). Let X be the minimum number of registers required by an *optimal* code generation (without any…
  9. GATE 2016 CS (CS1) Q29 (1 mark, Numerical answer) – Consider the following code segment. The minimum number of *total* variables required to convert the above code segment to *static single assignment*…
  10. GATE 2015 CS (CS1) Q47 (2 marks, Numerical answer) – The least number of temporary variables required to create a three-address code in static single assignment form for the expression q + r/3 + s - t *…
  11. GATE 2025 CS (CS2) Q21 (1 mark, Multiple choice) – Consider the following statements about the use of backpatching in a compiler for intermediate code generation: (I) Backpatching can be used to…
  12. GATE 2025 CS (CS1) Q52 (2 marks, Numerical answer) – Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is . (Answer in integer)
  13. GATE 2024 CS (CS2) Q21 (1 mark, Multiple choice) – Consider two sets. Set X: P. Lexical Analyzer, Q. Syntax Analyzer, R. Intermediate Code Generator, S. Code Optimizer. Set Y: 1. Abstract Syntax Tree,…
  14. GATE 2024 CS (CS2) Q43 (2 marks, Multiple choice) – Consider the expression x[i]=(p+r)*-s[i]+u/w. The triples are: (0) + p r; (1) ?; (2) uminus (1); (3) ?; (4) / u w; (5) + (3) (4); (6) ?; (7) = (6)…
  15. GATE 2024 CS (CS1) Q39 (2 marks, Multiple choice) – Consider the pseudo-code with lines L1: t1=−1; L2: t2=0; L3: t3=0; L4: t4=4*t3; L5: t5=4*t2; L6: t6=t5*M; L7: t7=t4+t6; L8: t8=a[t7]; L9: if t8<=max…