From: Daniel Schürmann Date: Wed, 24 Jun 2020 10:23:05 +0000 (+0100) Subject: nir: refactor nir_can_move_instr X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9300a14ffbac490906f62a638f9d8d6546298bfc;p=mesa.git nir: refactor nir_can_move_instr Reviewed-by: Rhys Perry Part-of: --- diff --git a/src/compiler/nir/nir_opt_sink.c b/src/compiler/nir/nir_opt_sink.c index 5595cfd61d9..1d551fe9f8b 100644 --- a/src/compiler/nir/nir_opt_sink.c +++ b/src/compiler/nir/nir_opt_sink.c @@ -39,37 +39,34 @@ bool nir_can_move_instr(nir_instr *instr, nir_move_options options) { - if ((options & nir_move_const_undef) && instr->type == nir_instr_type_load_const) { - return true; + switch (instr->type) { + case nir_instr_type_load_const: + case nir_instr_type_ssa_undef: { + return options & nir_move_const_undef; } - - if (instr->type == nir_instr_type_intrinsic) { - nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - if ((options & nir_move_load_ubo) && intrin->intrinsic == nir_intrinsic_load_ubo) - return true; - - if ((options & nir_move_load_input) && - (intrin->intrinsic == nir_intrinsic_load_interpolated_input || - intrin->intrinsic == nir_intrinsic_load_input || - intrin->intrinsic == nir_intrinsic_load_per_vertex_input)) - return true; - } - - if ((options & nir_move_const_undef) && instr->type == nir_instr_type_ssa_undef) { - return true; + case nir_instr_type_alu: { + if (nir_op_is_vec(nir_instr_as_alu(instr)->op)) + return options & nir_move_copies; + if (nir_alu_instr_is_comparison(nir_instr_as_alu(instr))) + return options & nir_move_comparisons; + return false; } - - if ((options & nir_move_copies) && instr->type == nir_instr_type_alu && - nir_op_is_vec(nir_instr_as_alu(instr)->op)) { - return true; + case nir_instr_type_intrinsic: { + nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); + switch (intrin->intrinsic) { + case nir_intrinsic_load_ubo: + return options & nir_move_load_ubo; + case nir_intrinsic_load_input: + case nir_intrinsic_load_interpolated_input: + case nir_intrinsic_load_per_vertex_input: + return options & nir_move_load_input; + default: + return false; + } } - - if ((options & nir_move_comparisons) && instr->type == nir_instr_type_alu && - nir_alu_instr_is_comparison(nir_instr_as_alu(instr))) { - return true; + default: + return false; } - - return false; } static nir_loop *