Fernando Magno Quintao Pereira
2007-Feb-17 22:51 UTC
[LLVMdev] Question about SSA-transformation
Dear LLVM'ers,
I'm producing code for the PowerPC, and many often times it happens
that the bytecodes generated by LLVM have phi-functions like:
A4 = phi(A1, A2)
A5 = phi(A1, A3)
Where the 'A1' parameter appears in two different phi-functions. Could
someone give me an example in "pseudo-assembly" that would produce
code
like that after being transformed into SSA form? Does it happen because of
some optimization, like in:
V = 1000;
if(...) {
A1 = 1;
A2 = 2;
} else {
A1 = V;
A2 = V;
}
use(A1);
use(A2);
Where one can remove the assignments that use 'V' by placing it directly
in the phi function, like in:
V = 1000;
if(...) {
A1 = 1;
A2 = 2;
}
A3 = phi(V, A1);
A4 = phi(V, A2);
Thanks,
Fernando
On Sat, 17 Feb 2007, Fernando Magno Quintao Pereira wrote:> I'm producing code for the PowerPC, and many often times it happens > that the bytecodes generated by LLVM have phi-functions like: > > A4 = phi(A1, A2) > A5 = phi(A1, A3)ok> Where the 'A1' parameter appears in two different phi-functions. Could > someone give me an example in "pseudo-assembly" that would produce code > like that after being transformed into SSA form? Does it happen because of > some optimization, like in:Right, SSA construction with copy propagation (which we do, because llvm has no copy instruction) can cause this.> V = 1000; > if(...) { > A1 = 1; > A2 = 2; > } else { > A1 = V; > A2 = V; > } > use(A1); > use(A2);Yep, exactly. -Chris -- http://nondot.org/sabre/ http://llvm.org/