diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 7f63cc40612..176d9c15145 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 0326725e1c0..5d8de704520 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 a859baafc7a..7c0fc129740 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; }