[Mesa-dev] [PATCH v3 10/12] nir/instr: Change "live" to a more generic "pass_flags" field

Connor Abbott cwabbott0 at gmail.com
Mon Feb 16 13:04:14 PST 2015


Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>

On Mon, Feb 9, 2015 at 11:24 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> ---
> This replaces the original patch 10 even though they are very different.
>
>  src/glsl/nir/nir.h         |  6 ++++--
>  src/glsl/nir/nir_opt_dce.c | 14 +++++++++-----
>  2 files changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index f4056f4..6ac1bfd 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -411,8 +411,10 @@ typedef struct {
>     nir_instr_type type;
>     struct nir_block *block;
>
> -   /* flag for dead code elimination (see nir_opt_dce.c) */
> -   bool live;
> +   /* A temporary for optimization and analysis passes to use for storing
> +    * flags.  For instance, DCE uses this to store the "dead/live" info.
> +    */
> +   uint8_t pass_flags;
>  } nir_instr;
>
>  static inline nir_instr *
> diff --git a/src/glsl/nir/nir_opt_dce.c b/src/glsl/nir/nir_opt_dce.c
> index 3f7d94d..e0ebdc6 100644
> --- a/src/glsl/nir/nir_opt_dce.c
> +++ b/src/glsl/nir/nir_opt_dce.c
> @@ -39,7 +39,7 @@ worklist_push(struct exec_list *worklist, nir_instr *instr)
>  {
>     worklist_elem *elem = ralloc(worklist, worklist_elem);
>     elem->instr = instr;
> -   instr->live = true;
> +   instr->pass_flags = 1;
>     exec_list_push_tail(worklist, &elem->node);
>  }
>
> @@ -56,7 +56,7 @@ mark_live_cb(nir_src *src, void *_state)
>  {
>     struct exec_list *worklist = (struct exec_list *) _state;
>
> -   if (src->is_ssa && !src->ssa->parent_instr->live) {
> +   if (src->is_ssa && !src->ssa->parent_instr->pass_flags) {
>        worklist_push(worklist, src->ssa->parent_instr);
>     }
>
> @@ -70,7 +70,11 @@ init_instr(nir_instr *instr, struct exec_list *worklist)
>     nir_intrinsic_instr *intrin_instr;
>     nir_tex_instr *tex_instr;
>
> -   instr->live = false;
> +   /* We use the pass_flags to store the live/dead information.  In DCE, we
> +    * just treat it as a zero/non-zerl boolean for whether or not the
> +    * instruction is live.
> +    */
> +   instr->pass_flags = 0;
>
>     switch (instr->type) {
>     case nir_instr_type_call:
> @@ -119,7 +123,7 @@ init_block_cb(nir_block *block, void *_state)
>     nir_if *following_if = nir_block_get_following_if(block);
>     if (following_if) {
>        if (following_if->condition.is_ssa &&
> -          !following_if->condition.ssa->parent_instr->live)
> +          !following_if->condition.ssa->parent_instr->pass_flags)
>           worklist_push(worklist, following_if->condition.ssa->parent_instr);
>     }
>
> @@ -132,7 +136,7 @@ delete_block_cb(nir_block *block, void *_state)
>     bool *progress = (bool *) _state;
>
>     nir_foreach_instr_safe(block, instr) {
> -      if (!instr->live) {
> +      if (!instr->pass_flags) {
>           nir_instr_remove(instr);
>           *progress = true;
>        }
> --
> 2.2.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list