Reviewed-by: Connor Abbott <cwabbo...@gmail.com>

On Mon, Feb 9, 2015 at 11:24 PM, Jason Ekstrand <ja...@jlekstrand.net> wrote:
> Being able to find the least common anscestor in the dominance tree is a
> useful thing that we may want to do in other passes.  In particular, we
> need it for GCM.
>
> v2: Handle NULL inputs by returning the other block
> ---
>  src/glsl/nir/nir.h           |  2 ++
>  src/glsl/nir/nir_dominance.c | 22 ++++++++++++++++++++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index 4cb2e92..886dcd2 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1500,6 +1500,8 @@ static inline void nir_validate_shader(nir_shader 
> *shader) { }
>  void nir_calc_dominance_impl(nir_function_impl *impl);
>  void nir_calc_dominance(nir_shader *shader);
>
> +nir_block *nir_dominance_lca(nir_block *b1, nir_block *b2);
> +
>  void nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp);
>  void nir_dump_dom_tree(nir_shader *shader, FILE *fp);
>
> diff --git a/src/glsl/nir/nir_dominance.c b/src/glsl/nir/nir_dominance.c
> index 67fdcc6..831b9a3 100644
> --- a/src/glsl/nir/nir_dominance.c
> +++ b/src/glsl/nir/nir_dominance.c
> @@ -212,6 +212,28 @@ nir_calc_dominance(nir_shader *shader)
>     }
>  }
>
> +/**
> + * Computes the least common anscestor of two blocks.  If one of the blocks
> + * is null, the other block is returned.
> + */
> +nir_block *
> +nir_dominance_lca(nir_block *b1, nir_block *b2)
> +{
> +   if (b1 == NULL)
> +      return b2;
> +
> +   if (b2 == NULL)
> +      return b1;
> +
> +   assert(nir_cf_node_get_function(&b1->cf_node) ==
> +          nir_cf_node_get_function(&b2->cf_node));
> +
> +   assert(nir_cf_node_get_function(&b1->cf_node)->valid_metadata &
> +          nir_metadata_dominance);
> +
> +   return intersect(b1, b2);
> +}
> +
>  static bool
>  dump_block_dom(nir_block *block, void *state)
>  {
> --
> 2.2.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to