<p dir="ltr">On Aug 1, 2016 12:37 AM, "Timothy Arceri" <<a href="mailto:timothy.arceri@collabora.com">timothy.arceri@collabora.com</a>> wrote:<br>
><br>
> These don't seem to have been used since d1d12efb36074.</p>
<p dir="ltr">I'm a bit torn...  On the one hand, I do think we will probably want to bring them back at some point in the future.  On the other hand, dead code is broken code...</p>
<p dir="ltr">> ---<br>
>  src/compiler/Makefile.sources               |   1 -<br>
>  src/compiler/nir/nir.c                      |  23 -------<br>
>  src/compiler/nir/nir.h                      |  14 ----<br>
>  src/compiler/nir/nir_clone.c                |   6 +-<br>
>  src/compiler/nir/nir_opt_global_to_local.c  | 102 ----------------------------<br>
>  src/compiler/nir/nir_print.c                |  10 +--<br>
>  src/compiler/nir/nir_sweep.c                |   1 -<br>
>  src/compiler/nir/nir_validate.c             |  39 +++--------<br>
>  src/gallium/drivers/freedreno/ir3/ir3_nir.c |   1 -<br>
>  src/gallium/drivers/vc4/vc4_program.c       |   2 -<br>
>  10 files changed, 10 insertions(+), 189 deletions(-)<br>
>  delete mode 100644 src/compiler/nir/nir_opt_global_to_local.c<br>
><br>
> diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources<br>
> index 0ff9b23..e23c52a 100644<br>
> --- a/src/compiler/Makefile.sources<br>
> +++ b/src/compiler/Makefile.sources<br>
> @@ -224,7 +224,6 @@ NIR_FILES = \<br>
>         nir/nir_opt_dce.c \<br>
>         nir/nir_opt_dead_cf.c \<br>
>         nir/nir_opt_gcm.c \<br>
> -       nir/nir_opt_global_to_local.c \<br>
>         nir/nir_opt_peephole_select.c \<br>
>         nir/nir_opt_remove_phis.c \<br>
>         nir/nir_opt_undef.c \<br>
> diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c<br>
> index 6bebb73..c0cc0cd 100644<br>
> --- a/src/compiler/nir/nir.c<br>
> +++ b/src/compiler/nir/nir.c<br>
> @@ -45,10 +45,8 @@ nir_shader_create(void *mem_ctx,<br>
>     memset(&shader->info, 0, sizeof(shader->info));<br>
><br>
>     exec_list_make_empty(&shader->functions);<br>
> -   exec_list_make_empty(&shader->registers);<br>
>     exec_list_make_empty(&shader->globals);<br>
>     exec_list_make_empty(&shader->system_values);<br>
> -   shader->reg_alloc = 0;<br>
><br>
>     shader->num_inputs = 0;<br>
>     shader->num_outputs = 0;<br>
> @@ -81,21 +79,10 @@ reg_create(void *mem_ctx, struct exec_list *list)<br>
>  }<br>
><br>
>  nir_register *<br>
> -nir_global_reg_create(nir_shader *shader)<br>
> -{<br>
> -   nir_register *reg = reg_create(shader, &shader->registers);<br>
> -   reg->index = shader->reg_alloc++;<br>
> -   reg->is_global = true;<br>
> -<br>
> -   return reg;<br>
> -}<br>
> -<br>
> -nir_register *<br>
>  nir_local_reg_create(nir_function_impl *impl)<br>
>  {<br>
>     nir_register *reg = reg_create(ralloc_parent(impl), &impl->registers);<br>
>     reg->index = impl->reg_alloc++;<br>
> -   reg->is_global = false;<br>
><br>
>     return reg;<br>
>  }<br>
> @@ -1061,16 +1048,6 @@ nir_index_local_regs(nir_function_impl *impl)<br>
>     impl->reg_alloc = index;<br>
>  }<br>
><br>
> -void<br>
> -nir_index_global_regs(nir_shader *shader)<br>
> -{<br>
> -   unsigned index = 0;<br>
> -   foreach_list_typed(nir_register, reg, node, &shader->registers) {<br>
> -      reg->index = index++;<br>
> -   }<br>
> -   shader->reg_alloc = index;<br>
> -}<br>
> -<br>
>  static bool<br>
>  visit_alu_dest(nir_alu_instr *instr, nir_foreach_dest_cb cb, void *state)<br>
>  {<br>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
> index 65ecd33..f354f78 100644<br>
> --- a/src/compiler/nir/nir.h<br>
> +++ b/src/compiler/nir/nir.h<br>
> @@ -363,9 +363,6 @@ typedef struct nir_register {<br>
>     /** only for debug purposes, can be NULL */<br>
>     const char *name;<br>
><br>
> -   /** whether this register is local (per-function) or global (per-shader) */<br>
> -   bool is_global;<br>
> -<br>
>     /**<br>
>      * If this flag is set to true, then accessing channels >= num_components<br>
>      * is well-defined, and simply spills over to the next array element. This<br>
> @@ -1877,12 +1874,6 @@ typedef struct nir_shader {<br>
><br>
>     struct exec_list functions; /** < list of nir_function */<br>
><br>
> -   /** list of global register in the shader */<br>
> -   struct exec_list registers;<br>
> -<br>
> -   /** next available global register index */<br>
> -   unsigned reg_alloc;<br>
> -<br>
>     /**<br>
>      * the highest index a load_input_*, load_uniform_*, etc. intrinsic can<br>
>      * access plus one<br>
> @@ -1912,8 +1903,6 @@ nir_shader *nir_shader_create(void *mem_ctx,<br>
>                                const nir_shader_compiler_options *options);<br>
><br>
>  /** creates a register, including assigning it an index and adding it to the list */<br>
> -nir_register *nir_global_reg_create(nir_shader *shader);<br>
> -<br>
>  nir_register *nir_local_reg_create(nir_function_impl *impl);<br>
><br>
>  void nir_reg_remove(nir_register *reg);<br>
> @@ -2275,7 +2264,6 @@ nir_if *nir_block_get_following_if(nir_block *block);<br>
>  nir_loop *nir_block_get_following_loop(nir_block *block);<br>
><br>
>  void nir_index_local_regs(nir_function_impl *impl);<br>
> -void nir_index_global_regs(nir_shader *shader);<br>
>  void nir_index_ssa_defs(nir_function_impl *impl);<br>
>  unsigned nir_index_instrs(nir_function_impl *impl);<br>
><br>
> @@ -2559,8 +2547,6 @@ bool nir_opt_algebraic(nir_shader *shader);<br>
>  bool nir_opt_algebraic_late(nir_shader *shader);<br>
>  bool nir_opt_constant_folding(nir_shader *shader);<br>
><br>
> -bool nir_opt_global_to_local(nir_shader *shader);<br>
> -<br>
>  bool nir_copy_prop(nir_shader *shader);<br>
><br>
>  bool nir_opt_cse(nir_shader *shader);<br>
> diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c<br>
> index 0e397b0..1a874e7 100644<br>
> --- a/src/compiler/nir/nir_clone.c<br>
> +++ b/src/compiler/nir/nir_clone.c<br>
> @@ -100,7 +100,7 @@ remap_global(clone_state *state, const void *ptr)<br>
>  static nir_register *<br>
>  remap_reg(clone_state *state, const nir_register *reg)<br>
>  {<br>
> -   return _lookup_ptr(state, reg, reg->is_global);<br>
> +   return _lookup_ptr(state, reg, false);<br>
>  }<br>
><br>
>  static nir_variable *<br>
> @@ -183,7 +183,6 @@ clone_register(clone_state *state, const nir_register *reg)<br>
>     nreg->num_array_elems = reg->num_array_elems;<br>
>     nreg->index = reg->index;<br>
>     nreg->name = ralloc_strdup(nreg, reg->name);<br>
> -   nreg->is_global = reg->is_global;<br>
>     nreg->is_packed = reg->is_packed;<br>
><br>
>     /* reconstructing uses/defs/if_uses handled by nir_instr_insert() */<br>
> @@ -707,9 +706,6 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s)<br>
>        nfxn->impl->function = nfxn;<br>
>     }<br>
><br>
> -   clone_reg_list(&state, &ns->registers, &s->registers);<br>
> -   ns->reg_alloc = s->reg_alloc;<br>
> -<br>
>     ns->info = s->info;<br>
>     ns-><a href="http://info.name">info.name</a> = ralloc_strdup(ns, ns-><a href="http://info.name">info.name</a>);<br>
>     if (ns->info.label)<br>
> diff --git a/src/compiler/nir/nir_opt_global_to_local.c b/src/compiler/nir/nir_opt_global_to_local.c<br>
> deleted file mode 100644<br>
> index 64d689e..0000000<br>
> --- a/src/compiler/nir/nir_opt_global_to_local.c<br>
> +++ /dev/null<br>
> @@ -1,102 +0,0 @@<br>
> -/*<br>
> - * Copyright © 2014 Intel Corporation<br>
> - *<br>
> - * Permission is hereby granted, free of charge, to any person obtaining a<br>
> - * copy of this software and associated documentation files (the "Software"),<br>
> - * to deal in the Software without restriction, including without limitation<br>
> - * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> - * and/or sell copies of the Software, and to permit persons to whom the<br>
> - * Software is furnished to do so, subject to the following conditions:<br>
> - *<br>
> - * The above copyright notice and this permission notice (including the next<br>
> - * paragraph) shall be included in all copies or substantial portions of the<br>
> - * Software.<br>
> - *<br>
> - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
> - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
> - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
> - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
> - * IN THE SOFTWARE.<br>
> - *<br>
> - * Authors:<br>
> - *    Connor Abbott (<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>)<br>
> - *<br>
> - */<br>
> -<br>
> -#include "nir.h"<br>
> -<br>
> -static bool<br>
> -global_to_local(nir_register *reg)<br>
> -{<br>
> -   nir_function_impl *impl = NULL;<br>
> -<br>
> -   assert(reg->is_global);<br>
> -<br>
> -   nir_foreach_def(def_dest, reg) {<br>
> -      nir_instr *instr = def_dest->reg.parent_instr;<br>
> -      nir_function_impl *instr_impl =<br>
> -         nir_cf_node_get_function(&instr->block->cf_node);<br>
> -      if (impl != NULL) {<br>
> -         if (impl != instr_impl)<br>
> -            return false;<br>
> -      } else {<br>
> -         impl = instr_impl;<br>
> -      }<br>
> -   }<br>
> -<br>
> -   nir_foreach_use(use_src, reg) {<br>
> -      nir_instr *instr = use_src->parent_instr;<br>
> -      nir_function_impl *instr_impl =<br>
> -         nir_cf_node_get_function(&instr->block->cf_node);<br>
> -      if (impl != NULL) {<br>
> -         if (impl != instr_impl)<br>
> -            return false;<br>
> -      } else {<br>
> -         impl = instr_impl;<br>
> -      }<br>
> -   }<br>
> -<br>
> -   nir_foreach_if_use(use_src, reg) {<br>
> -      nir_if *if_stmt = use_src->parent_if;<br>
> -      nir_function_impl *if_impl = nir_cf_node_get_function(&if_stmt->cf_node);<br>
> -      if (impl != NULL) {<br>
> -         if (impl != if_impl)<br>
> -            return false;<br>
> -      } else {<br>
> -         impl = if_impl;<br>
> -      }<br>
> -   }<br>
> -<br>
> -   if (impl == NULL) {<br>
> -      /* this instruction is never used/defined, delete it */<br>
> -      nir_reg_remove(reg);<br>
> -      return true;<br>
> -   }<br>
> -<br>
> -   /*<br>
> -    * if we've gotten to this point, the register is always used/defined in<br>
> -    * the same implementation so we can move it to be local to that<br>
> -    * implementation.<br>
> -    */<br>
> -<br>
> -   exec_node_remove(&reg->node);<br>
> -   exec_list_push_tail(&impl->registers, &reg->node);<br>
> -   reg->index = impl->reg_alloc++;<br>
> -   reg->is_global = false;<br>
> -   return true;<br>
> -}<br>
> -<br>
> -bool<br>
> -nir_opt_global_to_local(nir_shader *shader)<br>
> -{<br>
> -   bool progress = false;<br>
> -<br>
> -   foreach_list_typed_safe(nir_register, reg, node, &shader->registers) {<br>
> -      if (global_to_local(reg))<br>
> -         progress = true;<br>
> -   }<br>
> -<br>
> -   return progress;<br>
> -}<br>
> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c<br>
> index 3beb70a..74449b6 100644<br>
> --- a/src/compiler/nir/nir_print.c<br>
> +++ b/src/compiler/nir/nir_print.c<br>
> @@ -82,11 +82,7 @@ print_register(nir_register *reg, print_state *state)<br>
>  {<br>
>     FILE *fp = state->fp;<br>
>     if (reg->name != NULL)<br>
> -      fprintf(fp, "/* %s */ ", reg->name);<br>
> -   if (reg->is_global)<br>
> -      fprintf(fp, "gr%u", reg->index);<br>
> -   else<br>
> -      fprintf(fp, "r%u", reg->index);<br>
> +      fprintf(fp, "/* %s */ r%u", reg->name, reg->index);<br>
>  }<br>
><br>
>  static const char *sizes[] = { "error", "vec1", "vec2", "vec3", "vec4" };<br>
> @@ -1172,10 +1168,6 @@ nir_print_shader_annotated(nir_shader *shader, FILE *fp,<br>
>        print_var_decl(var, &state);<br>
>     }<br>
><br>
> -   foreach_list_typed(nir_register, reg, node, &shader->registers) {<br>
> -      print_register_decl(reg, &state);<br>
> -   }<br>
> -<br>
>     foreach_list_typed(nir_function, func, node, &shader->functions) {<br>
>        print_function(func, &state);<br>
>     }<br>
> diff --git a/src/compiler/nir/nir_sweep.c b/src/compiler/nir/nir_sweep.c<br>
> index 0f1debc..276c1ca 100644<br>
> --- a/src/compiler/nir/nir_sweep.c<br>
> +++ b/src/compiler/nir/nir_sweep.c<br>
> @@ -164,7 +164,6 @@ nir_sweep(nir_shader *nir)<br>
>     steal_list(nir, nir_variable, &nir->shared);<br>
>     steal_list(nir, nir_variable, &nir->globals);<br>
>     steal_list(nir, nir_variable, &nir->system_values);<br>
> -   steal_list(nir, nir_register, &nir->registers);<br>
><br>
>     /* Recurse into functions, stealing their contents back. */<br>
>     foreach_list_typed(nir_function, func, node, &nir->functions) {<br>
> diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c<br>
> index 63e85cf..8d9b706 100644<br>
> --- a/src/compiler/nir/nir_validate.c<br>
> +++ b/src/compiler/nir/nir_validate.c<br>
> @@ -146,10 +146,8 @@ validate_reg_src(nir_src *src, validate_state *state)<br>
>        _mesa_set_add(reg_state->if_uses, src);<br>
>     }<br>
><br>
> -   if (!src->reg.reg->is_global) {<br>
> -      validate_assert(state, reg_state->where_defined == state->impl &&<br>
> -             "using a register declared in a different function");<br>
> -   }<br>
> +   validate_assert(state, reg_state->where_defined == state->impl &&<br>
> +          "using a register declared in a different function");<br>
><br>
>     validate_assert(state, (src->reg.reg->num_array_elems == 0 ||<br>
>            src->reg.base_offset < src->reg.reg->num_array_elems) &&<br>
> @@ -262,10 +260,8 @@ validate_reg_dest(nir_reg_dest *dest, validate_state *state)<br>
>     reg_validate_state *reg_state = (reg_validate_state *) entry2->data;<br>
>     _mesa_set_add(reg_state->defs, dest);<br>
><br>
> -   if (!dest->reg->is_global) {<br>
> -      validate_assert(state, reg_state->where_defined == state->impl &&<br>
> -             "writing to a register declared in a different function");<br>
> -   }<br>
> +   validate_assert(state, reg_state->where_defined == state->impl &&<br>
> +          "writing to a register declared in a different function");<br>
><br>
>     validate_assert(state, (dest->reg->num_array_elems == 0 ||<br>
>            dest->base_offset < dest->reg->num_array_elems) &&<br>
> @@ -849,14 +845,9 @@ validate_cf_node(nir_cf_node *node, validate_state *state)<br>
>  }<br>
><br>
>  static void<br>
> -prevalidate_reg_decl(nir_register *reg, bool is_global, validate_state *state)<br>
> +prevalidate_reg_decl(nir_register *reg, validate_state *state)<br>
>  {<br>
> -   validate_assert(state, reg->is_global == is_global);<br>
> -<br>
> -   if (is_global)<br>
> -      validate_assert(state, reg->index < state->shader->reg_alloc);<br>
> -   else<br>
> -      validate_assert(state, reg->index < state->impl->reg_alloc);<br>
> +   validate_assert(state, reg->index < state->impl->reg_alloc);<br>
>     validate_assert(state, !BITSET_TEST(state->regs_found, reg->index));<br>
>     BITSET_SET(state->regs_found, reg->index);<br>
><br>
> @@ -872,7 +863,7 @@ prevalidate_reg_decl(nir_register *reg, bool is_global, validate_state *state)<br>
>     reg_state->defs = _mesa_set_create(reg_state, _mesa_hash_pointer,<br>
>                                        _mesa_key_pointer_equal);<br>
><br>
> -   reg_state->where_defined = is_global ? NULL : state->impl;<br>
> +   reg_state->where_defined = state->impl;<br>
><br>
>     _mesa_hash_table_insert(state->regs, reg, reg_state);<br>
>  }<br>
> @@ -1038,7 +1029,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state)<br>
>                                  sizeof(BITSET_WORD));<br>
>     exec_list_validate(&impl->registers);<br>
>     foreach_list_typed(nir_register, reg, node, &impl->registers) {<br>
> -      prevalidate_reg_decl(reg, false, state);<br>
> +      prevalidate_reg_decl(reg, state);<br>
>     }<br>
><br>
>     state->ssa_defs_found = realloc(state->ssa_defs_found,<br>
> @@ -1165,25 +1156,11 @@ nir_validate_shader(nir_shader *shader)<br>
>       validate_var_decl(var, true, &state);<br>
>     }<br>
><br>
> -   state.regs_found = realloc(state.regs_found,<br>
> -                              BITSET_WORDS(shader->reg_alloc) *<br>
> -                              sizeof(BITSET_WORD));<br>
> -   memset(state.regs_found, 0, BITSET_WORDS(shader->reg_alloc) *<br>
> -                               sizeof(BITSET_WORD));<br>
> -   exec_list_validate(&shader->registers);<br>
> -   foreach_list_typed(nir_register, reg, node, &shader->registers) {<br>
> -      prevalidate_reg_decl(reg, true, &state);<br>
> -   }<br>
> -<br>
>     exec_list_validate(&shader->functions);<br>
>     foreach_list_typed(nir_function, func, node, &shader->functions) {<br>
>        validate_function(func, &state);<br>
>     }<br>
><br>
> -   foreach_list_typed(nir_register, reg, node, &shader->registers) {<br>
> -      postvalidate_reg_decl(reg, &state);<br>
> -   }<br>
> -<br>
>     if (_mesa_hash_table_num_entries(state.errors) > 0)<br>
>        dump_errors(&state);<br>
><br>
> diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_nir.c<br>
> index 023da3b..33c5512 100644<br>
> --- a/src/gallium/drivers/freedreno/ir3/ir3_nir.c<br>
> +++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.c<br>
> @@ -141,7 +141,6 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,<br>
>                 debug_printf("----------------------\n");<br>
>         }<br>
><br>
> -       OPT_V(s, nir_opt_global_to_local);<br>
>         OPT_V(s, nir_convert_to_ssa);<br>
><br>
>         if (key) {<br>
> diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c<br>
> index 9057b86..950345f 100644<br>
> --- a/src/gallium/drivers/vc4/vc4_program.c<br>
> +++ b/src/gallium/drivers/vc4/vc4_program.c<br>
> @@ -1940,7 +1940,6 @@ nir_to_qir(struct vc4_compile *c)<br>
>          ntq_setup_inputs(c);<br>
>          ntq_setup_outputs(c);<br>
>          ntq_setup_uniforms(c);<br>
> -        ntq_setup_registers(c, &c->s->registers);</p>
<p dir="ltr">Did you really mean to delete this?</p>
<p dir="ltr">><br>
>          /* Find the main function and emit the body. */<br>
>          nir_foreach_function(function, c->s) {<br>
> @@ -2009,7 +2008,6 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,<br>
>          }<br>
><br>
>          c->s = nir_shader_clone(c, key->shader_state->base.ir.nir);<br>
> -        NIR_PASS_V(c->s, nir_opt_global_to_local);<br>
>          NIR_PASS_V(c->s, nir_convert_to_ssa);<br>
><br>
>          if (stage == QSTAGE_FRAG)<br>
> --<br>
> 2.7.4<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br></p>