Consider the following three-address code basic block:
t1 = a + b
t2 = t1 - c
t3 = t1 + d
t4 = t2 * t3
a = t4
t5 = a + b
Using DAG-based local optimization, which values are available as common subexpressions that can be eliminated?
GATE CSE · Compiler Design
Generate GATE-level questions covering three-address code, syntax trees, DAG, quadruples, triples, indirect triples, and translation schemes. Include representation and conversion problems.
60 questions · 0 PYQs · 20 AI practice · GATE CSE 2027
Consider the following three-address code basic block:
t1 = a + b
t2 = t1 - c
t3 = t1 + d
t4 = t2 * t3
a = t4
t5 = a + b
Using DAG-based local optimization, which values are available as common subexpressions that can be eliminated?
A basic block in a flow graph is defined as a maximal sequence of consecutive three-address instructions such that:
Consider the translation of the while loop:
while (a < b) do
a = a + 1;
The correct three-address code (with labels) is:
In the context of generating three-address code for boolean expressions using short-circuit (lazy) evaluation, consider the expression:
if (P AND Q AND R) then S1 else S2
How many conditional goto instructions are generated in the three-address code (excluding the unconditional goto)?
Consider the code segment for a procedure call f(a, b+c, d*e). How many three-address instructions are generated for this procedure call (including parameter evaluation and the actual call instruction)?
Which of the following is NOT a standard form of intermediate code used in compilers?
In the translation of array references to intermediate code, consider a 2D row-major array A[low1..high1][low2..high2] with element size w. The address formula for A[i][j] is:
base + ((i - low1) * n2 + (j - low2)) * w
where n2 = high2 - low2 + 1.
For A declared as A[1..4][1..4] with w=4 bytes, how many multiplications appear in the three-address code to compute the address of A[i][j]? (Without any strength reduction optimization)
Consider the following three-address instructions representing a loop:
(1) i = 1
(2) t1 = i * 4
(3) t2 = a[t1]
(4) if t2 > 0 goto (7)
(5) t3 = 0 - t2
(6) a[t1] = t3
(7) i = i + 1
(8) if i <= 10 goto (2)
What are the leaders of the basic blocks in this code? List the instruction numbers.
Consider the differences between Quadruples, Triples, and Indirect Triples as representations of three-address code. Which of the following statements are CORRECT? (Select all that apply)
The three-address code for the expression a = b * -c + b * -c is generated. Assuming no optimization, how many three-address instructions are generated?
Consider the arithmetic expression: a = (b + c) * (b + c) - d
How many nodes and edges does the DAG (Directed Acyclic Graph) for this expression have, assuming common subexpression elimination is applied?
Consider the following intermediate code (three-address code) basic block:
B1: t1 = a * a
B2: t2 = a * a
B3: t3 = t1 + t2
B4: t4 = t3 * b
B5: c = t4
After applying DAG-based common subexpression elimination and generating optimized three-address code, how many instructions remain?
Consider the following three-address code sequence:
t1 = a + b
t2 = t1 + c
t3 = t1 * d
t4 = t2 + t3
t5 = t4 - e
In the DAG representation of the above code, what is the number of leaf nodes?
Consider a flow graph derived from three-address code. Which of the following statements about flow graphs are CORRECT? (Select all that apply)
Consider the following three-address code:
(1) t1 = 4 * i
(2) t2 = a[t1]
(3) t3 = 4 * i
(4) t4 = b[t3]
(5) t5 = t2 * t4
(6) t6 = prod + t5
(7) prod = t6
(8) t7 = i + 1
(9) i = t7
(10) if i <= 20 goto (1)
Identify all the leaders in this basic block sequence to determine the number of basic blocks.
In Static Single Assignment (SSA) form, which of the following statements are CORRECT? (Select all that apply)
The following code is to be translated into three-address code:
for (i = 1; i <= n; i++)
A[i] = B[i] + C[i];
Assume each array element is 4 bytes wide, and base addresses of A, B, C are given. How many three-address instructions are generated for one complete iteration of the loop body ONLY (excluding loop initialization and loop condition check)?
In the context of intermediate code generation using backpatching, which of the following statements are TRUE? (Select all that apply)
Which of the following properties make three-address code (TAC) a preferred intermediate representation over direct machine code generation? (Select all that apply)
Consider the boolean expression: (a < b) OR (c > d) AND (e == f)
Assuming standard operator precedence (AND before OR), and using short-circuit evaluation to generate three-address code with backpatching, how many conditional jump instructions are generated?
Want unlimited AI-generated Intermediate Code Generation questions?
Sign up free and practice with adaptive difficulty — Easy, Medium, Hard. New questions every session.
Start practising for free →