From b6f31898a24adda853d8ac2ce3dff211a819c1cf Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 20 Aug 2020 14:42:30 -0500 Subject: [PATCH] nir: Use a switch in nir_inline_function_impl Acked-by: Daniel Stone Reviewed-by: Jesse Natalie Part-of: --- src/compiler/nir/nir_inline_functions.c | 48 ++++++++++++++----------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/compiler/nir/nir_inline_functions.c b/src/compiler/nir/nir_inline_functions.c index d7144b39a8d..03a26e0dbf3 100644 --- a/src/compiler/nir/nir_inline_functions.c +++ b/src/compiler/nir/nir_inline_functions.c @@ -44,27 +44,33 @@ void nir_inline_function_impl(struct nir_builder *b, nir_foreach_block(block, copy) { nir_foreach_instr_safe(instr, block) { - /* Returns have to be lowered for this to work */ - assert(instr->type != nir_instr_type_jump || - nir_instr_as_jump(instr)->type != nir_jump_return); - - if (instr->type != nir_instr_type_intrinsic) - continue; - - nir_intrinsic_instr *load = nir_instr_as_intrinsic(instr); - if (load->intrinsic != nir_intrinsic_load_param) - continue; - - unsigned param_idx = nir_intrinsic_param_idx(load); - assert(param_idx < impl->function->num_params); - assert(load->dest.is_ssa); - nir_ssa_def_rewrite_uses(&load->dest.ssa, - nir_src_for_ssa(params[param_idx])); - - /* Remove any left-over load_param intrinsics because they're soon - * to be in another function and therefore no longer valid. - */ - nir_instr_remove(&load->instr); + switch (instr->type) { + case nir_instr_type_intrinsic: { + nir_intrinsic_instr *load = nir_instr_as_intrinsic(instr); + if (load->intrinsic != nir_intrinsic_load_param) + break; + + unsigned param_idx = nir_intrinsic_param_idx(load); + assert(param_idx < impl->function->num_params); + assert(load->dest.is_ssa); + nir_ssa_def_rewrite_uses(&load->dest.ssa, + nir_src_for_ssa(params[param_idx])); + + /* Remove any left-over load_param intrinsics because they're soon + * to be in another function and therefore no longer valid. + */ + nir_instr_remove(&load->instr); + break; + } + + case nir_instr_type_jump: + /* Returns have to be lowered for this to work */ + assert(nir_instr_as_jump(instr)->type != nir_jump_return); + break; + + default: + break; + } } } -- 2.30.2