GATE 2015 CS – Question 47
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 ________.
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: 8
Explanation
In static single assignment form every value gets its own temporary. The expression needs one for each operation: $t_1 = r/3$, $t_2 = t * 5$, $t_3 = u * v$, $t_4 = t_3 / w$, $t_5 = q + t_1$, $t_6 = t_5 + s$, $t_7 = t_6 - t_2$ and $t_8 = t_7 + t_4$. That is 8 temporaries.