diff --git a/src/compiler/nir/nir_lower_returns.c b/src/compiler/nir/nir_lower_returns.c index 3ea69e25204..9c4881112e3 100644 --- a/src/compiler/nir/nir_lower_returns.c +++ b/src/compiler/nir/nir_lower_returns.c @@ -37,6 +37,8 @@ struct lower_returns_state { * needs to be predicated on the return flag variable. */ bool has_predicated_return; + + bool removed_unreachable_code; }; static bool lower_returns_in_cf_list(struct exec_list *cf_list, @@ -162,8 +164,9 @@ lower_returns_in_block(nir_block *block, struct lower_returns_state *state) */ return false; } else { + state->removed_unreachable_code = true; nir_cf_delete(&list); - return true; + return false; } } @@ -262,9 +265,11 @@ nir_lower_returns_impl(nir_function_impl *impl) state.loop = NULL; state.return_flag = NULL; state.has_predicated_return = false; + state.removed_unreachable_code = false; nir_builder_init(&state.builder, impl); bool progress = lower_returns_in_cf_list(&impl->body, &state); + progress = progress || state.removed_unreachable_code; if (progress) { nir_metadata_preserve(impl, nir_metadata_none);