in Compiler Design edited by
1,249 views
3 votes
3 votes

Consider the following code segment:

$c=b+a$

$e=c-a$

$f=c*e$

$h=c+a$

$i=h+f$

The minimum number of temporary variable required to convert the above code segment to static single assignment form is ________.


Doubt : Are we allowed to do minimizations in SSA? if YES then is it always the case, if NO when do we have to do it. Please clarify.

 

in Compiler Design edited by
1.2k views

4 Comments

No, You can not do the optimization before converting into SSA form. Optimization is a next phase of Intermediate Representation and SSA is a Type of IR which is widely used by various compilers because it makes various types of Optimizations easy like Dead Code Elimination, Constant Propagation etc.  

Moreover, the Given Code Code Segment is Already in SSA form, hence, we do not need any extra temporary variable to convert it into SSA.
4
4
I guess they have done this arithmetic simplication to reduce one temporary variable.

$c= b+a$

$e= c-a = (b+a)-a = b$
1
1
@Deepakk sir .. DAG is also intermediate representation form also right?  i have seen question using optimization while drawing DAG.. i also believe what you depicted is right but a lot of confusion on this topic..whether to perform optimization or not. neither amy previous gate question i hve found which can resolve the confusion
0
0

Please log in or register to answer this question.

Related questions