Phi node (source code)

= Phi node
{title2=$\phi$}

A <phi node> supplies the value at a join in <static single-assignment form> by selecting among values associated with incoming edges. In LLVM, it lists a value and predecessor <basic block> for each incoming edge, and <phi nodes> occur before ordinary operations in their block.<LLVM Language Reference Manual>[phi instruction, Arguments and Semantics]{ref}

For example, if the left branch defines `x1=10` and the right defines `x2=20`, the join can define `x3=phi(x1,left; x2,right)`. Arriving from the left gives ten; arriving from the right gives twenty. It does not average the arguments or evaluate both branches. At a loop header, another <phi node> can select an initial value on first entry and the updated value on later iterations. The node has one static definition even though its selected value can change across executions.