+++ title = "Phi-predication" author = "Yann Herklotz" tags = [] categories = [] backlinks = ["2b1d1", "2b1"] forwardlinks = ["2b1b"] zettelid = "2b1a" +++ Phi-predication \[1\] is a lightweight predication implementation where phi nodes are inserted in optimal positions instead of having predicated instructions. This makes it much better for out-of-order processors with deep pipelines, as there will be less pipeline stalls. This is because the predicate only needs to be evaluated at the time the phi-instruction is executed and not when the individual instructions are executed. For example, if there are two `mov` that are in two separate branches of a conditional statement, then the compare can first be executed, followed by the two `mov`, and then finally a phi instruction is executed which assigns the right value to the register.
\[1\] W. Chuang, B. Calder, and J. Ferrante, “Phi-predication for light-weight if-conversion,” in *International symposium on code generation and optimization, 2003. CGO 2003.*, Mar. 2003, pp. 179–190. doi: [10.1109/CGO.2003.1191544].
[10.1109/CGO.2003.1191544]: https://doi.org/10.1109/CGO.2003.1191544