[LLVMdev] Getting rid of phi instructions?

Eli Friedman eli.friedman at gmail.com
Tue Aug 30 09:19:18 PDT 2011


On Tue, Aug 30, 2011 at 9:12 AM, Teemu Rinta-aho
<teemu.rinta-aho at nomadiclab.com> wrote:
> Hi all,
>
> is there a pass to get rid of phi-instructions in a function? There's no loop involved.

reg2mem.

> I have a function approx. like this:
>
> void @func() {
> entry:
>        …
> bb1:
>        …
> bb2:
>        …
>        %tmp100 = phi i32 [ 0, bb1 ], [ 1, bb2 ] …
>        %tmp101 = getelementptr …, %tmp100
>        tail call void @anotherfunc(…, %tmp101)
>        ret void
> }
>
> I would like it to rather be something like this:
>
> void @func() {
> entry:
>        …
> bb1:
>        ...
>        %tmp90 = getelementptr …, %tmp89
>        tail call void @anotherfunc(%tmp90)
>        ret void
> bb2:
>        …
>        %tmp101 = getelementptr …, %tmp100
>        tail call void @anotherfunc(%tmp101)
>        ret void
> }

reg2mem won't do quite this transformation... not sure exactly what you need.

-Eli




More information about the llvm-dev mailing list