14 Qs · since 2011 · 21 marks · 0.8 marks/paperStandard yield
In GATE CS, Intermediate Code Generation (ICG) is tested through both theoretical/architectural concepts and precise algorithmic computations. Core recurring topics include Static… Guide
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 goto L11
L10: t1 = t8
L11: t3 = t3 + 1
L12: if t3 < M goto L4
L13: t2 = t2 + 1
L14: if t2 < N goto L3
L15: max = t1
Which one of…stmt -> if expr then expr else expr; stmt | ò
expr -> term relop term | term
term -> id | number
id -> a | b | c
number -> [0-9]
where relop is a relational operator (e.g., <, >, ...), ò refers to the empty statement, and if…x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;
The minimum number of total variables required to convert the above code segment to static single assignment form is _________ .X[i][j][k], the following intermediate code is generated by a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits.
t0 = i * 1024t1 = j * 32t2 = k * 4t3 = t1 + t0t4 = t3 + t2…Topic guide
In GATE CS, Intermediate Code Generation (ICG) is tested through both theoretical/architectural concepts and precise algorithmic computations. Core recurring topics include Static Single Assignment (SSA) form variable counting and renaming, basic block partitioning via leader identification, register allocation on expression trees (Sethi-Ullman / Ershov labeling), array address calculation in 3-address code, and IR structures (Triples, AST, CFG, backpatching). The topic maintains an even split between 1-mark conceptual questions and 2-mark procedural NAT/MCQ problems.
Static Single Assignment (SSA) Variable Counting and Translation
common · mixed · 1.5 marks · 2017, 2016, 2015
Given an arithmetic expression or a sequence of straight-line three-address code statements, candidates must compute the minimum number of temporary variables or total variables (including distinct unassigned input variables) required in SSA form, or select the correctly renamed SSA sequence.
Optimal Register Evaluation on Expression Trees / Load-Store Arch
occasional · mixed · 2 marks · 2017, 2011
Given an expression tree or complex arithmetic expression, determine the minimum number of registers needed to evaluate the expression without spilling on a load-store architecture (often utilizing Ershov/Sethi-Ullman numbers, accounting for immediate vs. memory operands).
Basic Block and Control Flow Analysis
occasional · mixed · 2 marks · 2024, 2017
Given a sequence of three-address code with conditional and unconditional jumps, identify the number of basic blocks, leaders, instructions in the largest basic block, or compute total control-flow paths through branching structures.
Array Address Calculation and Intermediate Code Decompilation
occasional · MCQ · 2 marks · 2024, 2014
Match or deduce array dimensions and element byte sizes from generated row-major intermediate offset calculations, or fill missing entries in IR data structures like Triples/Quadruples for array accesses.
Compiler Phase Boundaries and IR Conceptual Characteristics
common · MCQ · 1 marks · 2025, 2023, 2021, 2015
Evaluate statements regarding machine-independence vs. target-dependence in front-end/back-end, distinguish IRs (AST, CFG, TAC) from compiler data structures (Symbol table), and properties of backpatching in single-pass code generation.
Ershov / Sethi-Ullman Register Numbering
Determining the minimum number of registers required to evaluate a binary expression tree without memory spills on a load-store machine.
Row-Major 3D Array Offset Calculation
Deducing array dimensions () and element size () from generated 3-address code instructions for array indexing.
Total SSA Variables Count
Calculating total variables in an SSA-converted straight-line basic block where each assignment produces a fresh variable version.
Combinatorial Control Flow Paths
Computing execution paths through chained or nested conditional structures.
Shift from basic register allocation and architecture-oriented questions to structured IR manipulations (SSA form variable counts, basic blocks, Triples).
2024, 2017, 2016, 2015, 2011
Recent resurgence of 1-mark MSQ and conceptual MCQs targeting precise phase boundaries, IR definitions, and backpatching mechanisms.
2025, 2023, 2021
Fine-grained procedural questions on 3-address code representations, such as triple syntax conventions for array reads (`=[]`) vs array writes (`[]=`), appeared in recent iterations.
2024
Easy questions are purely conceptual checks on front-end/back-end partitioning, identifying intermediate representations (AST, CFG, TAC vs symbol table), or basic single-pass backpatching statements. Medium questions require multi-step procedural application: identifying leaders in 10-15 line 3-address code blocks, calculating SSA variable versions across re-assignments, parsing multi-dimensional array offset arithmetic, or applying Sethi-Ullman register allocation.