[LLVMdev] About Reg2Mem's DemotePHIToStack behavior.

Paul Vario paul.paul.mit at gmail.com
Fri May 30 01:06:47 PDT 2014


Hi Fellows,

    I have a question about why DemotePHIToStack inserts the StoreInst's
right before the terminator instruction of each incoming basic block.
Shouldn't it make more sense to put them immediate below where the original
incoming value was computed? For example,

           %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]

where, in the second incoming BB,

(front)              ......
                   some instructions here
                       ......
                   %nextindar = add one
(A)                    .....
                    several instructions here
(B)                    .....
                    br label %toindvar


   Reg2Mem puts the StoreInst at point (B), where I think it would make
more sense to put it at point (A). Are these ways two equivalent? Are there
any particular reason to choose what was implemented? Thanks a bunch.


Best Regards,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140530/4fd5716c/attachment.html>


More information about the llvm-dev mailing list