diff options
author | Jason Ekstrand <[email protected]> | 2020-05-15 15:31:50 -0500 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-19 17:21:23 +0000 |
commit | d011fbde5ceda9924bae389278e8a278eb2dd2cf (patch) | |
tree | 28dd7e166ec468a83367b78d29c3759e5e9a3db0 /src | |
parent | 8c87082c940ddba90e7bd0aefdf834eb2c335a74 (diff) |
nir: Use a switch statement in nir_handle_add_jump
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Reviewed-by: Karol Herbst <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5101>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/nir/nir_control_flow.c | 33 |
1 files 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"); } } |