From: Jason Ekstrand Date: Tue, 21 Jul 2020 16:32:38 +0000 (-0500) Subject: nir/split_per_member_structs: Inline split_variables_in_list X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=789ec95dcd18c155a9578b5d5f56cb0aab74c763;p=mesa.git nir/split_per_member_structs: Inline split_variables_in_list This lets us do one list walk instead of three. Reviewed-by: Iago Toral Quiroga Part-of: --- diff --git a/src/compiler/nir/nir_split_per_member_structs.c b/src/compiler/nir/nir_split_per_member_structs.c index 16cf1f23483..6c9b314002e 100644 --- a/src/compiler/nir/nir_split_per_member_structs.c +++ b/src/compiler/nir/nir_split_per_member_structs.c @@ -103,24 +103,6 @@ split_variable(struct nir_variable *var, nir_shader *shader, _mesa_hash_table_insert(var_to_member_map, var, members); } -static bool -split_variables_in_list(nir_shader *shader, nir_variable_mode mode, - struct hash_table *var_to_member_map, void *dead_ctx) -{ - bool progress = false; - - nir_foreach_variable_with_modes_safe(var, shader, mode) { - if (var->num_members == 0) - continue; - - split_variable(var, shader, var_to_member_map, dead_ctx); - exec_node_remove(&var->node); - progress = true; - } - - return progress; -} - static nir_deref_instr * build_member_deref(nir_builder *b, nir_deref_instr *deref, nir_variable *member) { @@ -177,12 +159,17 @@ nir_split_per_member_structs(nir_shader *shader) struct hash_table *var_to_member_map = _mesa_pointer_hash_table_create(dead_ctx); - progress |= split_variables_in_list(shader, nir_var_shader_in, - var_to_member_map, dead_ctx); - progress |= split_variables_in_list(shader, nir_var_shader_out, - var_to_member_map, dead_ctx); - progress |= split_variables_in_list(shader, nir_var_system_value, - var_to_member_map, dead_ctx); + nir_foreach_variable_with_modes_safe(var, shader, nir_var_shader_in | + nir_var_shader_out | + nir_var_system_value) { + if (var->num_members == 0) + continue; + + split_variable(var, shader, var_to_member_map, dead_ctx); + exec_node_remove(&var->node); + progress = true; + } + if (!progress) { ralloc_free(dead_ctx); return false;