From c15498afbe38b615c61e1c4f6e3a489c586fd73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 27 Mar 2024 14:58:28 -0400 Subject: [PATCH] nir/use_dominance: set the root as post-dominator of unmovable instructions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: ba54099dce6 - nir: add a utility computing post-dominance of SSA uses Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir_use_dominance.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_use_dominance.c b/src/compiler/nir/nir_use_dominance.c index 217e903454c..9dd73651c69 100644 --- a/src/compiler/nir/nir_use_dominance.c +++ b/src/compiler/nir/nir_use_dominance.c @@ -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;