nir: clarify some nit_loop_info member names
Following commits will introduce additional fields such as guessed_trip_count. Renaming these will help avoid confusion as our unrolling feature set grows. Reviewed-by: Thomas Helland <thomashelland90@gmail.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
@@ -1886,9 +1886,11 @@ typedef struct {
|
||||
/* Number of instructions in the loop */
|
||||
unsigned num_instructions;
|
||||
|
||||
/* How many times the loop is run (if known) */
|
||||
unsigned trip_count;
|
||||
bool is_trip_count_known;
|
||||
/* Maximum number of times the loop is run (if known) */
|
||||
unsigned max_trip_count;
|
||||
|
||||
/* Do we know the exact number of times the loop will be run */
|
||||
bool exact_trip_count_known;
|
||||
|
||||
/* Unroll the loop regardless of its size */
|
||||
bool force_unroll;
|
||||
|
@@ -527,7 +527,7 @@ find_trip_count(loop_info_state *state)
|
||||
{
|
||||
bool trip_count_known = true;
|
||||
nir_loop_terminator *limiting_terminator = NULL;
|
||||
int min_trip_count = -1;
|
||||
int max_trip_count = -1;
|
||||
|
||||
list_for_each_entry(nir_loop_terminator, terminator,
|
||||
&state->loop->info->loop_terminator_list,
|
||||
@@ -606,8 +606,8 @@ find_trip_count(loop_info_state *state)
|
||||
* iterations than previously (we have identified a more limiting
|
||||
* terminator) set the trip count and limiting terminator.
|
||||
*/
|
||||
if (min_trip_count == -1 || iterations < min_trip_count) {
|
||||
min_trip_count = iterations;
|
||||
if (max_trip_count == -1 || iterations < max_trip_count) {
|
||||
max_trip_count = iterations;
|
||||
limiting_terminator = terminator;
|
||||
}
|
||||
break;
|
||||
@@ -617,9 +617,9 @@ find_trip_count(loop_info_state *state)
|
||||
}
|
||||
}
|
||||
|
||||
state->loop->info->is_trip_count_known = trip_count_known;
|
||||
if (min_trip_count > -1)
|
||||
state->loop->info->trip_count = min_trip_count;
|
||||
state->loop->info->exact_trip_count_known = trip_count_known;
|
||||
if (max_trip_count > -1)
|
||||
state->loop->info->max_trip_count = max_trip_count;
|
||||
state->loop->info->limiting_terminator = limiting_terminator;
|
||||
}
|
||||
|
||||
@@ -639,7 +639,7 @@ force_unroll_array_access(loop_info_state *state, nir_deref_instr *deref)
|
||||
nir_deref_instr *parent = nir_deref_instr_parent(d);
|
||||
assert(glsl_type_is_array(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->max_trip_count)
|
||||
return true;
|
||||
|
||||
if (deref->mode & state->indirect_mask)
|
||||
|
@@ -181,7 +181,7 @@ simple_unroll(nir_loop *loop)
|
||||
nir_cf_list unrolled_lp_body;
|
||||
|
||||
/* Clone loop header and append to the loop body */
|
||||
for (unsigned i = 0; i < loop->info->trip_count; i++) {
|
||||
for (unsigned i = 0; i < loop->info->max_trip_count; i++) {
|
||||
/* Clone loop body */
|
||||
nir_cf_list_clone(&unrolled_lp_body, &loop_body, loop->cf_node.parent,
|
||||
remap_table);
|
||||
@@ -340,7 +340,7 @@ complex_unroll(nir_loop *loop, nir_loop_terminator *unlimit_term,
|
||||
* trip count == 1 we execute the code above the break twice and the
|
||||
* code below it once so we need clone things twice and so on.
|
||||
*/
|
||||
num_times_to_clone = loop->info->trip_count + 1;
|
||||
num_times_to_clone = loop->info->max_trip_count + 1;
|
||||
} else {
|
||||
/* Pluck out the loop header */
|
||||
nir_cf_extract(&lp_header, nir_before_block(header_blk),
|
||||
@@ -368,7 +368,7 @@ complex_unroll(nir_loop *loop, nir_loop_terminator *unlimit_term,
|
||||
|
||||
nir_cf_node_remove(&limiting_term->nif->cf_node);
|
||||
|
||||
num_times_to_clone = loop->info->trip_count;
|
||||
num_times_to_clone = loop->info->max_trip_count;
|
||||
}
|
||||
|
||||
/* In the terminator that we have no trip count for move everything after
|
||||
@@ -568,14 +568,14 @@ is_loop_small_enough_to_unroll(nir_shader *shader, nir_loop_info *li)
|
||||
{
|
||||
unsigned max_iter = shader->options->max_unroll_iterations;
|
||||
|
||||
if (li->trip_count > max_iter)
|
||||
if (li->max_trip_count > max_iter)
|
||||
return false;
|
||||
|
||||
if (li->force_unroll)
|
||||
return true;
|
||||
|
||||
bool loop_not_too_large =
|
||||
li->num_instructions * li->trip_count <= max_iter * LOOP_UNROLL_LIMIT;
|
||||
li->num_instructions * li->max_trip_count <= max_iter * LOOP_UNROLL_LIMIT;
|
||||
|
||||
return loop_not_too_large;
|
||||
}
|
||||
@@ -641,7 +641,7 @@ process_loops(nir_shader *sh, nir_cf_node *cf_node, bool *has_nested_loop_out)
|
||||
if (!is_loop_small_enough_to_unroll(sh, loop->info))
|
||||
goto exit;
|
||||
|
||||
if (loop->info->is_trip_count_known) {
|
||||
if (loop->info->exact_trip_count_known) {
|
||||
simple_unroll(loop);
|
||||
progress = true;
|
||||
} else {
|
||||
@@ -665,7 +665,7 @@ process_loops(nir_shader *sh, nir_cf_node *cf_node, bool *has_nested_loop_out)
|
||||
* limiting terminator just do a simple unroll as the second
|
||||
* terminator can never be reached.
|
||||
*/
|
||||
if (loop->info->trip_count == 0 && !limiting_term_second) {
|
||||
if (loop->info->max_trip_count == 0 && !limiting_term_second) {
|
||||
simple_unroll(loop);
|
||||
} else {
|
||||
complex_unroll(loop, terminator, limiting_term_second);
|
||||
|
Reference in New Issue
Block a user