in Compiler Design edited by
992 views
1 vote
1 vote
Consider the following three address code:

T1= a+b

T2= c+d

T3=a-b

T4= T1+T3

T5= T2+T1

T6 = T5+T4

T7 = c + T6

Number of nodes and edges in DAG of the above code?

If we'll do simplification , then T4 would be T4 = a+b+a-b => a+a , after this simplification T3 is not used anywhere in the program, so it can be eliminated or we'll include it in DAG??
in Compiler Design edited by
992 views

7 Comments

10 node and 12 edge . what is given ans??
0
0
after simplification T3 never where used so eliminate this.
0
0
Mine was also the same, but in made easy answer it is given 11 nodes and 14 edges, as they are not eliminating T3.
0
0
can you please provide any reference for this.
0
0
it may be wrong …
0
0
Anybody help please if they know this clearly.
0
0

 I’m getting ans as 10 vertices and 12 edges. I started from T7 and then going backwards upto T1. final equation will be T7=a+a+a+b+d+c+c. Now draw dag for this , you will get 10 vertices and 12 edges. Sorry I tried but not able to add pictures.

1
1

1 Answer

0 votes
0 votes

The answer will be minimum 10 nodes and 12 edges. The 3-address code order has to be maintained while elimination terms.