The Gateway to Computer Science Excellence
0 votes


Given the 3-address code for a basic block:


The number of registers that are needed to allocate this basic block with no spills are ________.?

My doubt here is :

  1. Is there any difference in question asking for minimum numbers of registers and minimum number of variables required for 3 address code?
  2. Can’t we optimize the above code using code motion?
  3. If the question ask only for number of variables required in three address code ! do we need to optimize before counting?
  4. If the question ask for minimum number of variables required in three address code, Only then should we optimize the code before counting?
in Compiler Design by Active (3.2k points)
edited by | 146 views
if it is asking for minimum, always you have to do optimization on code

variables are nothing but registers only... i mean that T1 = some temporary register.

@Shaik Masthan Then answer to above question should be 2 only but ME solutions has given 4!

yes minimum = 2

@Shaik Masthan thank you :)


@Shaik Masthan

how 2?

At first here we are storing a,b,c,d in 4 registers



 there is no need of storing a,b,c,d into registers ,because  load instructions are there so we loading data from memory location to register so need of storing .

$2$ is minimum.

$T1 = a + b$

$T2 = T1 + c$

$T1 = T2 + d$ (we don't need a + b again so we can use T1)

$a = T1$

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,384 answers
105,342 users