Time Left - 45:00 mins

GATE CS 2021 : Compiler Design 8 (App update required to attempt this test)

Attempt now to get your rank among 468 students!

Question 1

Which of the following is false?

Question 2

Consider the following code segment:

p q + r

s p/t

p s * u

s s * p

The minimum number of total variables required to convert the above code segment in three address code static single assignment form is ________.

Question 3

The following program uses six temporary variables p, q, r, s, t and u. The code is:

p = 6

q = 7

t=p*q

s = t + p

u = 8

u =s* p

s =p+ u

r = r * q

t = t +p

return t

Assuming that all operations take their operands from registers. The minimum number of registers needed to execute this program without spilling is ________.

Question 4

Which of the following is false?

Question 5

The least number of temporary variables required to create a three-address code in static single assignment form for the expression q + r / 3 + st * 5 + u * v /wis _____________.

Question 6

Consider the following control flow graph given below:

Which of the following is true for the above control flow graph?

Question 7

Consider the following code segment:

a = b + c;
c = a + x;
d = b + c;
b = a + x;

The minimum number of edges required in DAG from the above code segment to a static single assignment form is ________.

Question 8

Consider the following expression:

Total = sub1 + sub2 * 2

The total number of identifiers present in this expression are:

Question 9

A directed acyclic graph represents one form intermediate representation. The number of non-terminals nodes in DAG of

(b+c)*(b+c)

Question 10

Consider the following SSA code:

t1 = a – b;

t2 = t1 * c;

t3 = a – b;

t4 = t3 / t2

How many minimum variables are required in equivalent three address code for the above static single assignment code?

Question 11

The least number of temporary variables required to create a three-address code in static single assignment form for the expression a*b+c-d^f*g is__________________.

Question 12

Consider the intermediate code given below :

K=1

L2:S=1

L1:R1=8*K

R2=R1 + S

R3= 8* R2

B[R3]= 3

S++

IF S<=2 GOTO L1

K++

IF K<7 GOTO L2

The number of nodes and leaders in the control flow graph for the above code(written without spaces and in order) is?

Question 13

Consider the DAG with V={1,2,3,4,5,6}

1) 1 2 3 4 5 6

2) 1 3 2 4 5 6

3) 1 3 2 4 6 5

4) 3 2 4 1 6 5

How many of the above are correct topological sorting?

Question 14

During intermediate code generation , we use 3 - address code in which we have 3 forms available : Quadruples , Triples and Indirect Triples. Now consider the below statements :

S1 : In Quadruples , statements can be moved around

S2 : In Triples , space is not wasted.

S3 : In Indirect Triples , space is not wasted but access time increases.

Which is correct ?

Question 15

Consider the following syntax tree for the expression :
((a+b)-((b+a)*(a-b) ) )+((a-b)*(a+b) )

The letters A through I are used to name the nodes, and are not part of the expression tree. The operator labels of the interior nodes are the +, -, or * adjacent to the nodes. Assume that + and * are commutative operators, although - is not. Construct the expression DAG from this tree, treating + and * as commutative.
Which of the following statements is TRUE(T)/FALSE(F) about which nodes will be combined?
(i) B and C will be combined
(ii) D and H will be combined
(iii) E and C will not be combined
(iv) F and I will not be combined
(v) I and G will not be combined
  • 468 attempts
  • 1 upvote
  • 4 comments
Aug 29GATE & PSU CS