nir: Only force loop unrolling if we know it's a in/out/temp

If we don't know the actual mode then we can't get to the variable so
it's going to be a scratch or other indirect load anyway and we aren't
saving ourselves anything by unrolling the loop.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6332>
This commit is contained in:
Jason Ekstrand
2020-11-01 17:22:19 -06:00
committed by Marge Bot
parent fff78fc1c5
commit 0f94ff8a6a

View File

@@ -1112,11 +1112,13 @@ force_unroll_array_access(loop_info_state *state, nir_deref_instr *deref)
unsigned array_size = find_array_access_via_induction(state, deref, NULL);
if (array_size) {
if ((array_size == state->loop->info->max_trip_count) &&
(deref->mode & (nir_var_shader_in | nir_var_shader_out |
nir_var_shader_temp | nir_var_function_temp)))
nir_deref_mode_must_be(deref, nir_var_shader_in |
nir_var_shader_out |
nir_var_shader_temp |
nir_var_function_temp))
return true;
if (deref->mode & state->indirect_mask)
if (nir_deref_mode_must_be(deref, state->indirect_mask))
return true;
}