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
|
bool
|
||||||
nir_can_move_instr(nir_instr *instr, nir_move_options options)
|
nir_can_move_instr(nir_instr *instr, nir_move_options options)
|
||||||
{
|
{
|
||||||
if ((options & nir_move_const_undef) && instr->type == nir_instr_type_load_const) {
|
switch (instr->type) {
|
||||||
return true;
|
case nir_instr_type_load_const:
|
||||||
|
case nir_instr_type_ssa_undef: {
|
||||||
|
return options & nir_move_const_undef;
|
||||||
}
|
}
|
||||||
|
case nir_instr_type_alu: {
|
||||||
if (instr->type == nir_instr_type_intrinsic) {
|
if (nir_op_is_vec(nir_instr_as_alu(instr)->op))
|
||||||
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
return options & nir_move_copies;
|
||||||
if ((options & nir_move_load_ubo) && intrin->intrinsic == nir_intrinsic_load_ubo)
|
if (nir_alu_instr_is_comparison(nir_instr_as_alu(instr)))
|
||||||
return true;
|
return options & nir_move_comparisons;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
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 *
|
static nir_loop *
|
||||||
|
Reference in New Issue
Block a user