+++ title = "Phi instructions" author = "Yann Herklotz" tags = [] categories = [] backlinks = ["3a8"] forwardlinks = ["3a8b", "3a8a1"] zettelid = "3a8a" +++ One main difference between normal intermediate languages and SSA forms are phi nodes, which are needed to transform branching statements. By default, the translation from a non-SSA form to an SSA form can just be done by labelling each variable with an index, and then each new assignment to that variable increments the index by one. The last index is then used by each instruction that uses that variable, which means that the transformation is semantics preserving. However, this is not the case when one can have multiple branches from multiple locations to a block. In this case, one needs to add phi instructions to assign the right value to the register. The phi instructions is defined as a function which returns the argument according to which predecessor executed the instruction. This means that branching instructions can be executed correctly.