nir/use_dominance: set the root as post-dominator of unmovable instructions

Some uses don't have any post-dominator. An example is an atomic that
feeds itself in a loop. No instruction immediately post-dominates
the result of such an atomic because no instruction can strictly
post-dominate itself. This handles that case generally by setting
the root node as the post-dominator for instructions that can't be
reordered.

Fixes: ba54099dce - nir: add a utility computing post-dominance of SSA uses

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28436>
This commit is contained in:
Marek Olšák 2024-03-27 14:58:28 -04:00 committed by Marge Bot
parent edf07649f4
commit c15498afbe
1 changed files with 6 additions and 1 deletions

View File

@ -177,7 +177,12 @@ calc_dominance(struct nir_use_dominance_state *state,
nir_def *def = nir_instr_def(node->instr);
bool has_use = false;
if (def) {
/* Intrinsics that can't be reordered will get the root node as
* the post-dominator.
*/
if (def &&
(node->instr->type != nir_instr_type_intrinsic ||
nir_intrinsic_can_reorder(nir_instr_as_intrinsic(node->instr)))) {
nir_foreach_use_including_if(src, def) {
has_use = true;