The Gateway to Computer Science Excellence
+22 votes
3.8k views

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 by Veteran (424k points)
edited by | 3.8k views
–3
A answer.i think
+7
@Uddipto no its b)
0
why? we can clear p1 and load u-v to p1 again
+4
Yes but Static Single Assignment says that a variable cannot be used more than once in the LHS, and it is to be initialised atmost once.
0
In static single assigment we can assign only once bu read many times
0
yes but cant we completely clear the variable.. then reassign again
0
till I didn't understand what is static single assignment??
+1
a = b;

a = 5;

This is not SSA because a is assigned value more than once. More detailed explanation is given in the selected answer.
0
In option B , in the last line, rightmost var should be q4 not q.

Correct me?
+2

Here option (B), not typed correctly.

0

B IS CORRECT A IS WRONG 

4 Answers

+34 votes
+6

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.

+13 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
by Active (3.4k points)
0 votes
Answer is B.
by (19 points)
0 votes
OPTION B becoz in option A same variable is used p1 , q1 which creates ambiguity also bt in option B different variable is used .
by (433 points)
0
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

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,647 questions
56,467 answers
195,381 comments
100,317 users