# Intermediate Code Generation

 Question 1
In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?
 A Three address code B Abstract Syntax Tree (AST) C Control Flow Graph (CFG) D Symbol table
GATE CSE 2021 SET-2   Compiler Design
Question 1 Explanation:
 Question 2
Which of the following is a type of a out-of-order execution, with the reordering done by a compiler
 A loop unrolling B dead code elimination C strength reduction D software pipelining
ISRO CSE 2020   Compiler Design
Question 2 Explanation:
 Question 3
Consider the productions $A\rightarrow PQ$ and $A\rightarrow XY$. Each of the five non-terminals A,P,Q,X, and Y has two attributes: s is a synthesized attribute, and i is an inherited attribute. Consider the following rules.

Rule 1: P.i=A.i+2, Q.i=P.i+A.i, and A.s=P.s+Q.s
Rule 2: X.i=A.i+Y.s and Y.i=X.s+A.i

Which one of the following is TRUE?
 A Both Rule 1 and Rule 2 are L-attributed. B Only Rule 1 is L-attributed. C Only Rule 2 is L-attributed. D Neither Rule 1 nor Rule 2 is L-attributed.
GATE CSE 2020   Compiler Design
Question 3 Explanation:
 Question 4
Which of the following comment about peep-hole optimization is true?
 A It is applied to small part of the code and applied repeatedly B It can be used to optimize intermediate code C It can be applied to a portion of the code that is not contiguous D It is applied in symbol table to optimize the memory requirements.
ISRO CSE 2018   Compiler Design
Question 4 Explanation:
 Question 5
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 register spill) algorithm for a load/store architecture in which (i) only loads and store instructions can have memory operands and (ii) arithmetic instructions can have only register or immediate operands. The value of X is _________.
 A 2 B 3 C 4 D 5
GATE CSE 2017 SET-1   Compiler Design
Question 5 Explanation:
 Question 6
Consider the following intermediate program in three address code
p= a -b
q= p *c
p= u * v
q= p + q
Which one of the following corresponds to a static single assignment form of the above code?
 A $p_{1}=a-b$$q_{1}=p_{1}*c$$p_{1}=u*v$$q_{1}=p_{1}+q_{1}$ B $p_{3}=a-b$$q_{4}=p_{3}*c$$p_{4}=u*v$$q_{3}=p_{4}+q_{4}$ C $p_{1}=a-b$$q_{1}=p_{2}*c$$p_{3}=u*v$$q_{2}=p_{4}+q_{3}$ D $p_{1}=a-b$$q_{1}=p_{1}*c$$p_{2}=u*v$$q_{2}=p+q$
GATE CSE 2017 SET-1   Compiler Design
Question 6 Explanation:
 Question 7
Peephole optimization is form of
 A Loop optimization B Local optimization C Constant folding D Data flow analysis
ISRO CSE 2016   Compiler Design
Question 7 Explanation:
 Question 8
Consider the following code segment.
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__________ .
 A 8 B 9 C 10 D 11
GATE CSE 2016 SET-1   Compiler Design
Question 8 Explanation:
 Question 9
Consider the intermediate code given below.
(1) i = 1
(2) j = 1
(3) t1 = 5 * i
(4) t2 = t1 + j
(5) t3 = 4 * t2
(6) t4 = t3
(7) a[t4] = -1
(8) j = j + 1
(9) if j$\leq$5 goto (3)
(10) i=i+1
(11) if i$\lt$5 goto (2)
The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are
 A 5 and 7 B 6 and 7 C 5 and 5 D 7 and 8
GATE CSE 2015 SET-2   Compiler Design
Question 9 Explanation:
 Question 10
In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is TRUE?
 A In both AST and CFG, let node N2 be the successor of node N1. In the input program, the code corresponding to N2 is present after the code corresponding to N1 B For any input program, neither AST nor CFG will contain a cycle C The maximum number of successors of a node in an AST and a CFG depends on the input program D Each node in AST and CFG corresponds to at most one statement in the input program
GATE CSE 2015 SET-2   Compiler Design
Question 10 Explanation:
There are 10 questions to complete.

### 1 thought on “Intermediate Code Generation”

1. In Q.6 “q” should be “q=p+q” instead of “q=p-q”.