I got answer as 3 minimum variables, if we are not using SSA

x=u-t

x=x*u

x=x+u

t=t-u

t=x*t

Dark Mode

22,276 views

64 votes

Consider the following code segment.

x = u - t; y = x * v; x = y + w; y = t - z; y = x * y;

The minimum number of *total* variables required to convert the above code segment to *static single assignment* form is __________.

0

@Abhishek Tank your approach and the answer both are correct .

It can also be done like

x1 = u – t

y1 = x1 * v

x2 = y1 + w

y2 = t – z

y3 = x2 – y2

Note :- SSA form does not do common subexpression elimination.

0

93 votes

Best answer

In Static Single Assignment when we assign the values, the variables to which the value is being assigned should be unique.

$T1 = u - t$

$T2 = T1 \ast v$

$T3 = T2 +w$

$T4 = t-z$

$T5 = t3 \ast t4$

So $T1 \ldots T5 =5 + (u,t,v,w,z)=5$

Total **10** variables.

Note: RHS of the operation can use the previously used variables, but LHS in SSA must always be unique.

https://gateoverflow.in/260068/3-address-code?show=260091#c260091

Why in question in above link they have not counted variables in rhs.

0