phi node as an operand

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>]



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

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.