nir: add nir_has_divergent_loop function

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13966>
This commit is contained in:
Marek Olšák
2021-11-18 23:14:26 -05:00
committed by Marge Bot
parent 26b522eae5
commit 2785141c16
2 changed files with 17 additions and 0 deletions

View File

@@ -5128,6 +5128,7 @@ void nir_convert_loop_to_lcssa(nir_loop *loop);
bool nir_convert_to_lcssa(nir_shader *shader, bool skip_invariants, bool skip_bool_invariants); bool nir_convert_to_lcssa(nir_shader *shader, bool skip_invariants, bool skip_bool_invariants);
void nir_divergence_analysis(nir_shader *shader); void nir_divergence_analysis(nir_shader *shader);
bool nir_update_instr_divergence(nir_shader *shader, nir_instr *instr); bool nir_update_instr_divergence(nir_shader *shader, nir_instr *instr);
bool nir_has_divergent_loop(nir_shader *shader);
/* If phi_webs_only is true, only convert SSA values involved in phi nodes to /* If phi_webs_only is true, only convert SSA values involved in phi nodes to
* registers. If false, convert all values (even those not involved in a phi * registers. If false, convert all values (even those not involved in a phi

View File

@@ -1022,3 +1022,19 @@ bool nir_update_instr_divergence(nir_shader *shader, nir_instr *instr)
return true; return true;
} }
bool
nir_has_divergent_loop(nir_shader *shader)
{
bool divergent_loop = false;
nir_function_impl *func = nir_shader_get_entrypoint(shader);
foreach_list_typed(nir_cf_node, node, node, &func->body) {
if (node->type == nir_cf_node_loop && nir_cf_node_as_loop(node)->divergent) {
divergent_loop = true;
break;
}
}
return divergent_loop;
}