nir: refactor nir_can_move_instr
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5622>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
if ((options & nir_move_copies) && instr->type == nir_instr_type_alu &&
|
||||
nir_op_is_vec(nir_instr_as_alu(instr)->op)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((options & nir_move_comparisons) && instr->type == nir_instr_type_alu &&
|
||||
nir_alu_instr_is_comparison(nir_instr_as_alu(instr))) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static nir_loop *
|
||||
|
Reference in New Issue
Block a user