Hi all, Is it possible to have phi nodes as an operand to an instruction? For example, instead of %input = phi <ty> [ <val0>, <label0>] [<val1>, <label1>] %2 = ..... %add = add i32 %2, %input we have sth like this: %add = add i32 %2, %phi <ty> [ <val0>, <label0>] [<val1>, <label1>] Best, Mo -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160115/fb4411ee/attachment.html>
On 1/15/16 9:44 AM, Mohammad Norouzi via llvm-dev wrote:> Hi all, > > Is it possible to have phi nodes as an operand to an instruction?Yes, you can use a phi node as an operand to an instruction. However, the phi-node must dominate any instruction that uses it as an operand. Regards, John Criswell> > For example, instead of > > %input = phi <ty> [ <val0>, <label0>] [<val1>, <label1>] %2 = ..... > %add = add i32 %2, %input > > we have sth like this: > %add = add i32 %2, %phi <ty> [ <val0>, <label0>] [<val1>, <label1>] > Best, > Mo > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- John Criswell Assistant Professor Department of Computer Science, University of Rochester http://www.cs.rochester.edu/u/criswell -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160115/4e222dd4/attachment.html>
On 15 January 2016 at 06:44, Mohammad Norouzi via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Is it possible to have phi nodes as an operand to an instruction?You mean you don't want to name the value "%input" but inline it into another instruction? That's not possible. Only the operations listed under "constant expressions" in the IR reference[1] can be fused like that. The concept roughly corresponds to things you'd expect to be able to write into an object file as a relocation. Cheers. Tim. [1] http://llvm.org/docs/LangRef.html#constant-expressions