diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c index 9ad45cb1a8c..3bcac93302c 100644 --- a/src/compiler/nir/nir_from_ssa.c +++ b/src/compiler/nir/nir_from_ssa.c @@ -974,7 +974,22 @@ place_phi_read(nir_builder *b, nir_register *reg, * single block to convert all of its phis to a register and some movs. * The code that is generated, while not optimal for actual codegen in a * back-end, is easy to generate, correct, and will turn into the same set of - * phis after you call regs_to_ssa and do some copy propagation. + * phis after you call regs_to_ssa and do some copy propagation. For each phi + * node we do the following: + * + * 1. For each phi instruction in the block, create a new nir_register + * + * 2. Insert movs at the top of the destination block for each phi and + * rewrite all uses of the phi to use the mov. + * + * 3. For each phi source, insert movs in the predecessor block from the phi + * source to the register associated with the phi. + * + * Correctness is guaranteed by the fact that we create a new register for + * each phi and emit movs on both sides of the control-flow edge. Because all + * the phis have SSA destinations (we assert this) and there is a separate + * temporary for each phi, all movs inserted in any particular block have + * unique destinations so the order of operations does not matter. * * The one intelligent thing this pass does is that it places the moves from * the phi sources as high up the predecessor tree as possible instead of in