[LLVMdev] Undoing SSA and Phi instructions

Nick Lewycky nicholas at mxc.ca
Sat Jan 22 22:45:12 PST 2011


On 01/22/2011 10:30 PM, Surinder wrote:
> Hi,
>
> I am emitting llvm bit code using
>
> llvm-gcc -c -emit-llvm -O0 -o test.bc test.c
>
> and then optimizing it with
>
> opt -O3 -print-module test.bc
>
> in order to obtain a dump of generated IR.
>
>
> The resulting code has Phi nodes and is perhaps in SSA form.  I want
> to undo the SSA form while retaining all the other optimizations.  Is
> mem2reg the right optimization to be added after -O3, i.e.,
>
> opt -O3 -mem2reg -print-module test.bc
>
> will print the llvm in non-SSA form with no Phi nodes.

I think you're looking for "opt -O3 -reg2mem -S test.bc" though I don't 
think it *guarantees* that it will remove all phi nodes. I don't think 
we have anything besides codegen that does.

Nick



More information about the llvm-dev mailing list