nir: small tidy ups for nir_loop_analyze()
Reviewed-by: Thomas Helland <thomashelland90@gmail.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
@@ -624,8 +624,7 @@ find_trip_count(loop_info_state *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
force_unroll_array_access(loop_info_state *state, nir_shader *ns,
|
force_unroll_array_access(loop_info_state *state, nir_deref_instr *deref)
|
||||||
nir_deref_instr *deref)
|
|
||||||
{
|
{
|
||||||
for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
|
for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
|
||||||
if (d->deref_type != nir_deref_type_array)
|
if (d->deref_type != nir_deref_type_array)
|
||||||
@@ -640,23 +639,18 @@ force_unroll_array_access(loop_info_state *state, nir_shader *ns,
|
|||||||
nir_deref_instr *parent = nir_deref_instr_parent(d);
|
nir_deref_instr *parent = nir_deref_instr_parent(d);
|
||||||
assert(glsl_type_is_array(parent->type) ||
|
assert(glsl_type_is_array(parent->type) ||
|
||||||
glsl_type_is_matrix(parent->type));
|
glsl_type_is_matrix(parent->type));
|
||||||
if (glsl_get_length(parent->type) == state->loop->info->trip_count) {
|
if (glsl_get_length(parent->type) == state->loop->info->trip_count)
|
||||||
state->loop->info->force_unroll = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
if (deref->mode & state->indirect_mask) {
|
if (deref->mode & state->indirect_mask)
|
||||||
state->loop->info->force_unroll = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
force_unroll_heuristics(loop_info_state *state, nir_shader *ns,
|
force_unroll_heuristics(loop_info_state *state, nir_block *block)
|
||||||
nir_block *block)
|
|
||||||
{
|
{
|
||||||
nir_foreach_instr(instr, block) {
|
nir_foreach_instr(instr, block) {
|
||||||
if (instr->type != nir_instr_type_intrinsic)
|
if (instr->type != nir_instr_type_intrinsic)
|
||||||
@@ -670,12 +664,12 @@ force_unroll_heuristics(loop_info_state *state, nir_shader *ns,
|
|||||||
if (intrin->intrinsic == nir_intrinsic_load_deref ||
|
if (intrin->intrinsic == nir_intrinsic_load_deref ||
|
||||||
intrin->intrinsic == nir_intrinsic_store_deref ||
|
intrin->intrinsic == nir_intrinsic_store_deref ||
|
||||||
intrin->intrinsic == nir_intrinsic_copy_deref) {
|
intrin->intrinsic == nir_intrinsic_copy_deref) {
|
||||||
if (force_unroll_array_access(state, ns,
|
if (force_unroll_array_access(state,
|
||||||
nir_src_as_deref(intrin->src[0])))
|
nir_src_as_deref(intrin->src[0])))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (intrin->intrinsic == nir_intrinsic_copy_deref &&
|
if (intrin->intrinsic == nir_intrinsic_copy_deref &&
|
||||||
force_unroll_array_access(state, ns,
|
force_unroll_array_access(state,
|
||||||
nir_src_as_deref(intrin->src[1])))
|
nir_src_as_deref(intrin->src[1])))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -745,15 +739,10 @@ get_loop_info(loop_info_state *state, nir_function_impl *impl)
|
|||||||
find_trip_count(state);
|
find_trip_count(state);
|
||||||
|
|
||||||
nir_shader *ns = impl->function->shader;
|
nir_shader *ns = impl->function->shader;
|
||||||
foreach_list_typed_safe(nir_cf_node, node, node, &state->loop->body) {
|
nir_foreach_block_in_cf_node(block, &state->loop->cf_node) {
|
||||||
if (node->type == nir_cf_node_block) {
|
if (force_unroll_heuristics(state, block)) {
|
||||||
if (force_unroll_heuristics(state, ns, nir_cf_node_as_block(node)))
|
state->loop->info->force_unroll = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
nir_foreach_block_in_cf_node(block, node) {
|
|
||||||
if (force_unroll_heuristics(state, ns, block))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user