From d011fbde5ceda9924bae389278e8a278eb2dd2cf Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 15 May 2020 15:31:50 -0500 Subject: [PATCH] nir: Use a switch statement in nir_handle_add_jump Reviewed-by: Caio Marcelo de Oliveira Filho Reviewed-by: Karol Herbst Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_control_flow.c | 33 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c index 252aaf335ad..c52d091e848 100644 --- a/src/compiler/nir/nir_control_flow.c +++ b/src/compiler/nir/nir_control_flow.c @@ -471,21 +471,28 @@ nir_handle_add_jump(nir_block *block) nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node); nir_metadata_preserve(impl, nir_metadata_none); - if (jump_instr->type == nir_jump_break || - jump_instr->type == nir_jump_continue) { + switch (jump_instr->type) { + case nir_jump_return: + link_blocks(block, impl->end_block, NULL); + break; + + case nir_jump_break: { nir_loop *loop = nearest_loop(&block->cf_node); + nir_cf_node *after = nir_cf_node_next(&loop->cf_node); + nir_block *after_block = nir_cf_node_as_block(after); + link_blocks(block, after_block, NULL); + break; + } - if (jump_instr->type == nir_jump_continue) { - nir_block *first_block = nir_loop_first_block(loop); - link_blocks(block, first_block, NULL); - } else { - nir_cf_node *after = nir_cf_node_next(&loop->cf_node); - nir_block *after_block = nir_cf_node_as_block(after); - link_blocks(block, after_block, NULL); - } - } else { - assert(jump_instr->type == nir_jump_return); - link_blocks(block, impl->end_block, NULL); + case nir_jump_continue: { + nir_loop *loop = nearest_loop(&block->cf_node); + nir_block *first_block = nir_loop_first_block(loop); + link_blocks(block, first_block, NULL); + break; + } + + default: + unreachable("Invalid jump type"); } } -- 2.30.2