diff --git a/src/compiler/nir/nir_opt_loop.c b/src/compiler/nir/nir_opt_loop.c index cfc9099607d..1f996854146 100644 --- a/src/compiler/nir/nir_opt_loop.c +++ b/src/compiler/nir/nir_opt_loop.c @@ -396,6 +396,12 @@ opt_loop_peel_initial_break(nir_loop *loop) !is_block_empty(nir_if_first_else_block(nif))) return false; + /* If do_work_2() ends in a break (presumably with a continue somewhere) + * then we can't move it to the top of the loop ahead of do_work_1() + */ + if (nir_block_ends_in_break(nir_loop_last_block(loop))) + return false; + /* Check that there is actual work to be done after the initial break. */ if (!block_contains_work(nir_cf_node_cf_tree_next(if_node))) return false;