[Mesa-dev] [PATCH] nir: Allow opt_peephole_select to work on empty blocks.

Jason Ekstrand jason at jlekstrand.net
Mon Aug 1 18:53:01 UTC 2016


On Aug 1, 2016 12:41 PM, "Eric Anholt" <eric at anholt.net> wrote:
>
> nir_opt_peephole_select has the job of removing IF statements with no side
> effects.  However, if the IF statement's successor didn't have any
> instructions in it, we were skipping it, which occurred in mupen64 on
> vc4 with glsl_to_nir enabled:

Ugh... This makes sense.  I do keep thinking that, one day, this should be
rolled into dead_cf...  Oh well

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

> instructions in affected programs:     6134 -> 4120 (-32.83%)
> total uniforms in shared programs: 38268 -> 38219 (-0.13%)
>
> No changes on Haswell shader-db.
> ---
>
> The comment abou the end block is concerning, but I think actually the
> end block doesn't get iterated over.  I would be surprised if HSW
> shader-db didn't crash if the end block was actually visited.

As of recent block iteration changes, we no longer hit the end block using
nir_foreach_block so it should be ok.

>  src/compiler/nir/nir_opt_peephole_select.c | 7 -------
>  1 file changed, 7 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_peephole_select.c
b/src/compiler/nir/nir_opt_peephole_select.c
> index 7fcc71ea9d76..633e9f486c08 100644
> --- a/src/compiler/nir/nir_opt_peephole_select.c
> +++ b/src/compiler/nir/nir_opt_peephole_select.c
> @@ -127,13 +127,6 @@ block_check_for_allowed_instrs(nir_block *block)
>  static bool
>  nir_opt_peephole_select_block(nir_block *block, void *mem_ctx)
>  {
> -   /* If the block is empty, then it certainly doesn't have any phi
nodes,
> -    * so we can skip it.  This also ensures that we do an early skip on
the
> -    * end block of the function which isn't actually attached to the CFG.
> -    */
> -   if (exec_list_is_empty(&block->instr_list))
> -      return false;
> -
>     if (nir_cf_node_is_first(&block->cf_node))
>        return false;
>
> --
> 2.8.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160801/5016f665/attachment.html>


More information about the mesa-dev mailing list