From 8fb6cbdcb67b969b9cba64b8d816538f1a0f75a9 Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Thu, 24 Dec 2020 10:23:33 -0600 Subject: [PATCH] nir: store the results of divergence analysis on loops MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir.c | 2 ++ src/compiler/nir/nir.h | 1 + src/compiler/nir/nir_divergence_analysis.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 7f63cc4..176d9c1 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -465,6 +465,8 @@ nir_loop_create(nir_shader *shader) nir_loop *loop = rzalloc(shader, nir_loop); cf_init(&loop->cf_node, nir_cf_node_loop); + /* Assume that loops are divergent until proven otherwise */ + loop->divergent = true; nir_block *body = nir_block_create(shader); exec_list_make_empty(&loop->body); diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 0326725..5d8de70 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2783,6 +2783,7 @@ typedef struct { nir_loop_info *info; nir_loop_control control; bool partially_unrolled; + bool divergent; } nir_loop; /** diff --git a/src/compiler/nir/nir_divergence_analysis.c b/src/compiler/nir/nir_divergence_analysis.c index a859baa..7c0fc12 100644 --- a/src/compiler/nir/nir_divergence_analysis.c +++ b/src/compiler/nir/nir_divergence_analysis.c @@ -890,6 +890,8 @@ visit_loop(nir_loop *loop, struct divergence_state *state) loop_state.divergent_loop_break); } + loop->divergent = (loop_state.divergent_loop_break || loop_state.divergent_loop_continue); + return progress; } -- 2.7.4