in Compiler Design edited by
1,679 views
1 vote
1 vote
What is the Static Single Assignment (SSA) form for the following code segment:

a = b+c;

c = a+x;

d = b+c;

d = a+x;

Should we use only 1 temporary variable for c=a+x and d=a+x because both of them evaluate the same expression finally?
in Compiler Design edited by
1.7k views

4 Comments

@JEET we definitely cannot have two same variables on the left.... So i feel the answer should be 7. But I'm not sure whether we can optimize the code prior to converting it to SSA form. If we can, then the answer would be 6 otherwise 7 (according to me)
0
0
A guy told me that you can't optimize in SSA and but can optimize in DAG.
Do someone have any authenticate content to read this topic.
I didn't found anything in the Ulman as well.
0
0

But I'm not sure whether we can optimize the code prior to converting it to SSA form.

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.  

Answer will be :

$a_0 = b_0+c_0;$

$c_1 = a_0+x_0;$

$d_0 = b_0+c_1;$

$d_1 = a_0+x_0;$

5
5

Please log in or register to answer this question.

Related questions