Mesa (main): nir: add nir_has_divergent_loop function
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Dec 11 20:39:57 UTC 2021
Module: Mesa
Branch: main
Commit: 2785141c1618e79028cf70d178ff36dac7c18ce4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2785141c1618e79028cf70d178ff36dac7c18ce4
Author: Marek Olšák <marek.olsak at amd.com>
Date: Thu Nov 18 23:14:26 2021 -0500
nir: add nir_has_divergent_loop function
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13966>
---
src/compiler/nir/nir.h | 1 +
src/compiler/nir/nir_divergence_analysis.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
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;
+}
More information about the mesa-commit
mailing list