nir: Add a correctness note for nir_lower_phis_to_regs_block
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16111>
This commit is contained in:
parent
4a4d6cdc80
commit
eb0d571ce4
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue