Instruction as Value in PHI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Instruction as Value in PHI

Ryan Taylor-5
Curious, is there a pass/mechanism that exists to promote an instruction that is a value of a PHI?

For example, if one of the incoming values is a sub(x, y) from BB2, does there exist something to promote this instruction back to BB2 (such that tmp = sub(x,y)) and the PHI replaces the sub instr with tmp?

Or is the above the natural state that is then optimized into using sub, is there a call that does this that I can turn off?

Thanks.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Instruction as Value in PHI

Eli Friedman-2
On Thu, Sep 20, 2012 at 3:18 PM, Ryan Taylor <[hidden email]> wrote:
> Curious, is there a pass/mechanism that exists to promote an instruction
> that is a value of a PHI?
>
> For example, if one of the incoming values is a sub(x, y) from BB2, does
> there exist something to promote this instruction back to BB2 (such that tmp
> = sub(x,y)) and the PHI replaces the sub instr with tmp?
>
> Or is the above the natural state that is then optimized into using sub, is
> there a call that does this that I can turn off?

It sounds like you're talking about a ConstantExpr.  Those don't
normally get lowered until CodeGen.  You could expand it at the IR
level, but there isn't any builtin function to do that IIRC.

-Eli
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Instruction as Value in PHI

Ryan Taylor-5
Ah, I see. This is my instruction:

%lsr.iv125.us.ph = phi i32 [ %lsr.iv.next126.us, %limit.exit281.i.us ], [ sub (i32 0, i32 ptrtoint ([8 x [2 x i32]]* @Maxlogmap_Decode_next_state to i32)), %for.cond195.preheader.i.us ]

So there is a ptrtoint inside a sub inside a phi.

I'm just going to write a pass that promotes/demotes the embedded instr, shouldn't take long.

Thanks,



On Thu, Sep 20, 2012 at 3:33 PM, Eli Friedman <[hidden email]> wrote:
On Thu, Sep 20, 2012 at 3:18 PM, Ryan Taylor <[hidden email]> wrote:
> Curious, is there a pass/mechanism that exists to promote an instruction
> that is a value of a PHI?
>
> For example, if one of the incoming values is a sub(x, y) from BB2, does
> there exist something to promote this instruction back to BB2 (such that tmp
> = sub(x,y)) and the PHI replaces the sub instr with tmp?
>
> Or is the above the natural state that is then optimized into using sub, is
> there a call that does this that I can turn off?

It sounds like you're talking about a ConstantExpr.  Those don't
normally get lowered until CodeGen.  You could expand it at the IR
level, but there isn't any builtin function to do that IIRC.

-Eli


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev