[LLVMdev] eliminate phi nodes, reduce unnecessary loads / stores , reg2mem, mem2reg

Reid Kleckner reid.kleckner at gmail.com
Tue May 17 10:04:15 PDT 2011


Generally, no.  For variables with multiple assignments, you can
either have loads and stores to allocas, or virtual registers with phi
nodes.  This is a feature of LLVM IR, there is no non-SSA form using
virtual registers.

Is it possible for you to run reg2mem, your pass, and then mem2reg
again?  That's the intended usage of reg2mem.

Reid

On Tue, May 17, 2011 at 10:09 AM, Jimborean Alexandra
<xinfinity_a at yahoo.com> wrote:
> Hi,
>
> I work on a pass that requires as input LLVM code without any phi nodes. For
> this, I use the reg2mem pass which produces suitable code, the pass runs
> correctly, but I obtain a significant performance decrease. I expect that
> this is because there are more reads / writes to memory after running the
> reg2mem pass.
> How can I optimize the code, without inserting any phi nodes? Or is there a
> better solution to eliminate the phi nodes in the first place?
>
> The solution that comes to my mind is to run a custom version of the mem2reg
> pass. That would mean, after running the reg2mem pass, to eliminate
> unnecessary load / store instructions, if this can be done without inserting
> any phi nodes.
>
> Do you think this can be achieved and is it the right way to go?
>
> Thank you,
> Alexandra
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>




More information about the llvm-dev mailing list