Process-Scheduling
January 28, 2025
Number-Systems
January 28, 2025
Process-Scheduling
January 28, 2025
Number-Systems
January 28, 2025

GATE 2017 [Set-1]

Question 12

Consider the following intermediate program in three address code

           p = a - b
           q = p * c
           p = u * v
           q = p + q

Which of the following corresponds to a static single assignment form of the above code?

A
B
C
D
Question 12 Explanation: 
Static Single Assignment is used for intermediate code in compiler design.

In Static Single Assignment form (SSA) each assignment to a variable should be specified with distinct names.
We use subscripts to distinguish each definition of variables.

In the given code segment, there are two assignments of the variable p
p = a-b
p = u*v
and two assignments of the variable q
q = p*c
q = p+q

So we use two variables p1, p2 for specifying distinct assignments of p and q1, q2 for
each assignment of q.
Static Single Assignment form(SSA) of the given code segment is:
p1 = a-b
q1 = p1 * c
p2 = u * v
q2 = p2 + q1
Note:
As per options, given in GATE 2017 answer is B.

p3 = a – b
q4 = p3 * c
p4 = u * v
q5 = p4 + q4

Correct Answer: B
Question 12 Explanation: 
Static Single Assignment is used for intermediate code in compiler design.

In Static Single Assignment form (SSA) each assignment to a variable should be specified with distinct names.
We use subscripts to distinguish each definition of variables.

In the given code segment, there are two assignments of the variable p
p = a-b
p = u*v
and two assignments of the variable q
q = p*c
q = p+q

So we use two variables p1, p2 for specifying distinct assignments of p and q1, q2 for
each assignment of q.
Static Single Assignment form(SSA) of the given code segment is:
p1 = a-b
q1 = p1 * c
p2 = u * v
q2 = p2 + q1
Note:
As per options, given in GATE 2017 answer is B.

p3 = a – b
q4 = p3 * c
p4 = u * v
q5 = p4 + q4

Leave a Reply

Your email address will not be published. Required fields are marked *