in Compiler Design
707 views
0 votes
0 votes

Min number of register needed for this program without spilling ?

in Compiler Design
707 views

9 Comments

edited by

@Kabir5454 Is the answer 4?

0
0
No given is 3. But i am getting 2.
0
0

0
0

@Kabir5454 im also getting 2...could u share at which statement and why are they taking the 3rd register?

0
0
They used different approach like drawing a graph and calculating chromatic number to solve this .
0
0
here operand also get from register  hence  minimum  register is 3
0
0

@Kabir5454

i think we can use labeling algo for such questions.

0
0
@pranav if u r getting 3reg as ans...can u post ur sol
0
0
I am also getting 2 registers only,

a = 1        //           R1 = a

b = a+ 2 //             R1 =a , R2 =b

c = a + b //            R1 = c , R2 = b

d = b + 5 //            R1 = c , R2 = d

e = 6       //           R1 = c , R2 = e

f = c + e  //           R1 = c , R2 = f

a = f + 7 //            R1 = a , R2 = f

c = a + f  //           R1 = a , R2 = c

e = a + c //           R1 = e , R2 = c

d = c +2 //            R1 = d
0
0

1 Answer

0 votes
0 votes
No. Of register is  3 ,4...Is Fine But my work done with 2 Register so why we use 3 register . That Why Minimum No. of Register Is 2