summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2021-11-18 23:14:26 -0500
committerMarge Bot <emma+marge@anholt.net>2021-12-11 20:07:35 +0000
commit2785141c1618e79028cf70d178ff36dac7c18ce4 (patch)
tree5adad6f10079120298f5cac785b546baa32df41c
parent26b522eae54b5b71e769672ea39b822ff97e8ea6 (diff)
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>
-rw-r--r--src/compiler/nir/nir.h1
-rw-r--r--src/compiler/nir/nir_divergence_analysis.c16
2 files changed, 17 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index a36c09589ce..d9e22f1fc20 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -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);
void nir_divergence_analysis(nir_shader *shader);
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
* registers. If false, convert all values (even those not involved in a phi
diff --git a/src/compiler/nir/nir_divergence_analysis.c b/src/compiler/nir/nir_divergence_analysis.c
index 739aa6cf8fc..20bbd8f8ae4 100644
--- a/src/compiler/nir/nir_divergence_analysis.c
+++ b/src/compiler/nir/nir_divergence_analysis.c
@@ -1022,3 +1022,19 @@ bool nir_update_instr_divergence(nir_shader *shader, nir_instr *instr)
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;
+}