Hi, On Sun, 10 Feb 2013, Richard Biener wrote:
> >> Consider the following example: > >> > >> if (...) > >> a_1 = 5; > >> else if (...) > >> a_2 = 2; > >> else > >> a_3 = 13; > >> > >> # a_4 = PHI <a_1, a_2, a_3> > >> return a_4; > >> > >> Do you mean that I treat a_1, a_2 and a_3 as 3 different variables? In > >> this approach, I lose the information that they are actually the same > >> variables. > >> > >> Or should I write a mini lexer function to convert the SSA names into > >> original variable names by removing _1, _2, etc. as suffix from each? > >> > >> Regarding PHI nodes, I think you mean, I should treat them as identity > >> functions, but I am not clear exactly how in the first approach above. > >> In second, I can just treat it as a=a. > > > > > > Richard means that you can treat the above code as > > > > > > if (...) { > > a_1 = 5; > > a_4 = a_1; > > > > } else if (...) { > > a_2 = 2; > > a_4 = a_2; > > } else { > > a_3 = 13; > > a_4 = a_3; > > } > > return a_4; > > > > The extra code above is "copies on CFG edges". Even that needs to be done carefully, due to the parallel assignment nature of PHIs (lost copy and swap problem). In absense of real parallel copies (which we have only on RTL) you also must use new temporaries for the LHS of PHIs. I think it makes more sense to adjust the value numbering algorithm to directly work with SSA form than to implicitely go out of SSA. Ciao, Michael.