Undoing SSA and Phi instructions

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.

Surinder

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

reg2mem inserts allocas to store values going into phis. It doesn't
exactly undo SSA, but it should remove all phis.

Andrew