in Compiler Design retagged by
3,557 views
2 votes
2 votes
The minimum number of variables required in 3 address code of the given expression are:______

a * b * c + d - a + e * f - g + h

Order of precedence: * > + > - ; with * as left associative and +,- as right associative.
in Compiler Design retagged by
3.6k views

4 Comments

After rules of associativity and precedencce, if we think of last expression as E1 - E2, if we evaluate E1, then answer is 3, but if we evaluate E2 first, we would be getting 2 as the minimum answer. -> explained below.

t1 = e*f

t1 = t1+a

t2 = g+h

t2 = t1 - t2

t1 = a*b

t1 = t1*c

t1 = t1+d

t1= t1-t2

Shouldn't minimum answer be 2? Am i doing anything wrong here?
3
3
3 ?
0
0

 because they r not asking for SSA

0
0

1 Answer

0 votes
0 votes

@Sambhrant Mayura

The question is asking only about the "MINIMUM number of variables for 3 Address Code". It is NOT asking the "Static Single Assignment" of 3 Address Code. Hence the variables on LHS can be repeated, which cannot be done in Static Single Assignment. You can refer this link.

I hope you doubt is clear by now.