in Compiler Design edited by
11,471 views
36 votes
36 votes

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?

  1. p1 = a  - b
    q1 = p1 * c
    p1 = u  * v
    q1 = p1 + q1
  2. p3 = a  - b
    q4 = p3 * c
    p4 = u  * v
    q5 = p4 + q4
  3. p1 = a  - b
    q1 = p2 * c
    p3 = u  * v
    q2 = p4 + q3
  4. p1 = a - b
    q1 = p * c
    p2 = u * v
    q2 = p + q
    
in Compiler Design edited by
by
11.5k views

4 Comments

B IS CORRECT A IS WRONG 

0
0

In option A – the 3rd expression is overridden when again p1 is used.

In option C – the 2nd expression is wrong as p2 is not initialized before but used.

In option D – the 2nd  expression is wrong as p is not initialized before but used.

Here each and every variable used are distinct. So the answer is (B).

0
0

Detailed Video Solution: GATE CSE 2017 - Static Single Assignment Form SSA Question

Static Single Assignment Form SSA Complete Lecturehttps://www.youtube.com/watch?v=CQV8hSeMrx8  

0
0

4 Answers

40 votes
40 votes

1 comment

In compiler design, static single assignment form (often abbreviated as SSA form or simply SSA) is a property of an intermediate representation (IR), which requires that each variable is assigned exactly once, and every variable is defined before it is used. Thus option B only satisfies the above criteria.

11
11
16 votes
16 votes
Option D INCORRECT because in last line we are directly adding P+Q without moving it to register

option C INCORRECT because in last line Q3+P4 is done however they dont even contain any value

Option A INCORRECT because P1 has been assigned value twice

So OPTION (B) is CORRECT
1 vote
1 vote
Answer is B.
1 vote
1 vote
OPTION B becoz in option A same variable is used p1 , q1 which creates ambiguity also bt in option B different variable is used .

1 comment

But in option B, last line q5= p4 + q

instead of it should be q5= p4+ q4 because q is pointing to value  of statement 2

Please correct me if i am wrong
0
0