retagged by
28,736 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__________________.
retagged by

7 Answers

1 votes
1 votes

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.

 

 

–2 votes
–2 votes
Answer is 3.
Answer:

Related questions