mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
nir/loop_analyze: ignore terminating induction variable in guess_loop_limit()
The array access might be using a different induction variable. Totals from 23 (0.03% of 79395) affected shaders: (Navi31) Instrs: 113742 -> 121017 (+6.40%) CodeSize: 592152 -> 636228 (+7.44%) Latency: 439244 -> 426784 (-2.84%) InvThroughput: 36264 -> 35199 (-2.94%) SClause: 3048 -> 3426 (+12.40%) Copies: 10630 -> 10733 (+0.97%) Branches: 3774 -> 4310 (+14.20%) PreSGPRs: 1683 -> 1696 (+0.77%) PreVGPRs: 1230 -> 1232 (+0.16%) VALU: 51026 -> 55912 (+9.58%) SALU: 15270 -> 15638 (+2.41%) SMEM: 4456 -> 5149 (+15.55%) Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33131>
This commit is contained in:
parent
7eb2e96d16
commit
de30bfd5b8
1 changed files with 16 additions and 24 deletions
|
|
@ -447,11 +447,10 @@ find_array_access_via_induction(loop_info_state *state,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
guess_loop_limit(loop_info_state *state, nir_const_value *limit_val,
|
||||
nir_scalar basic_ind)
|
||||
static unsigned
|
||||
guess_loop_limit(loop_info_state *state)
|
||||
{
|
||||
unsigned min_array_size = 0;
|
||||
unsigned min_array_size = UINT_MAX;
|
||||
|
||||
nir_foreach_block_in_cf_node(block, &state->loop->cf_node) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
|
|
@ -470,12 +469,8 @@ guess_loop_limit(loop_info_state *state, nir_const_value *limit_val,
|
|||
find_array_access_via_induction(state,
|
||||
nir_src_as_deref(intrin->src[0]),
|
||||
&array_idx);
|
||||
if (array_idx && basic_ind.def == array_idx->def &&
|
||||
(min_array_size == 0 || min_array_size > array_size)) {
|
||||
/* Array indices are scalars */
|
||||
assert(basic_ind.def->num_components == 1);
|
||||
min_array_size = array_size;
|
||||
}
|
||||
if (array_idx)
|
||||
min_array_size = MIN2(min_array_size, array_size);
|
||||
|
||||
if (intrin->intrinsic != nir_intrinsic_copy_deref)
|
||||
continue;
|
||||
|
|
@ -484,23 +479,16 @@ guess_loop_limit(loop_info_state *state, nir_const_value *limit_val,
|
|||
find_array_access_via_induction(state,
|
||||
nir_src_as_deref(intrin->src[1]),
|
||||
&array_idx);
|
||||
if (array_idx && basic_ind.def == array_idx->def &&
|
||||
(min_array_size == 0 || min_array_size > array_size)) {
|
||||
/* Array indices are scalars */
|
||||
assert(basic_ind.def->num_components == 1);
|
||||
min_array_size = array_size;
|
||||
}
|
||||
if (array_idx)
|
||||
min_array_size = MIN2(min_array_size, array_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (min_array_size) {
|
||||
*limit_val = nir_const_value_for_uint(min_array_size,
|
||||
basic_ind.def->bit_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (min_array_size != UINT_MAX)
|
||||
return min_array_size;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static nir_op invert_comparison_if_needed(nir_op alu_op, bool invert);
|
||||
|
|
@ -1194,7 +1182,11 @@ find_trip_count(loop_info_state *state, unsigned execution_mode,
|
|||
|
||||
if (!try_find_limit_of_alu(limit, &limit_val, alu_op, invert_cond, terminator, state)) {
|
||||
/* Guess loop limit based on array access */
|
||||
if (!guess_loop_limit(state, &limit_val, basic_ind)) {
|
||||
unsigned guessed_loop_limit = guess_loop_limit(state);
|
||||
if (guessed_loop_limit) {
|
||||
limit_val = nir_const_value_for_uint(guessed_loop_limit,
|
||||
basic_ind.def->bit_size);
|
||||
} else {
|
||||
terminator->exact_trip_count_unknown = true;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue