in Compiler Design retagged by
28,713 views
80 votes
80 votes
The least number of temporary variables required to create a three-address code in static single assignment form for the expression $q  + r / 3 + s - t * 5 + u * v/w$ is__________________.
in Compiler Design retagged by
28.7k views

4 Comments

4 temprorary variables are required if SSA is not asked
1
1

The least number of temporary variables required to create a three-address code in static single assignment form: $8$

The least number of total variables required to create a three-address code in static single assignment form: $8 + 7(q,r,s,t,u,v,w) = 15$

Problem related to total variables: GATE2016-1-19

0
0

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

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

0
0

7 Answers

1 vote
1 vote

8 variables are required.

Static Single Assignment(SSA)

A variable cannot appear more than one on the left hand side of assignment operator. 

Lets try this definition for the given expression: 

q+r/3+s-t×5+u*v/w

here, we have 3 operators, multiplication, addition & division. We have to keep in mind the precedence & associativity of them. 

Associativity: left to right

precedence: 1. * & /  2. +

A=r/3

B=t×5

C=u×v

C1=C/w

A1=A+q

A2=A1+s

A3=A2-B

A4= A3+C1

SSA variable set: {A,B,C,A1,A2,A3,A4,C1}

Minimum number of variables=8.

 

 

0 votes
0 votes

Answes is 15 (8 temp) (8 memory)

–2 votes
–2 votes
Answer is 3.

3 Comments

how?
0
0
–2
–2
Answer is 8. It was given by official GATE key.
10
10