[Mesa-dev] [PATCH 2/2] i965/cfg: Ignore non-CF instructions in unreachable blocks.

Iago Toral itoral at igalia.com
Thu Aug 18 10:43:55 UTC 2016


On Wed, 2016-08-17 at 11:54 -0700, Matt Turner wrote:
> The basic block following a control flow structure like an infinite
> loop
> will be unreachable. Ignore any non-control-flow instructions in it
> since they can have no effect on the program.

If the block is unreachable control-flow instructions inside the block
are also irrelevant, is there any reason why you don't skip CF
instructions too?

> Avoids a segmentation fault in cfg_t::intersect(a, b) when called on
> an
> unreachable block. By avoiding ever putting code in an unreachable
> block, we never attempt to optimize code in an unreachable block.

Can't the problem persist if the unreachable block has any control-flow 
instructions?

> ---
>  src/mesa/drivers/dri/i965/brw_cfg.cpp | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp
> b/src/mesa/drivers/dri/i965/brw_cfg.cpp
> index 53b32be..2fa4e3d 100644
> --- a/src/mesa/drivers/dri/i965/brw_cfg.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp
> @@ -312,6 +312,11 @@ cfg_t::cfg_t(exec_list *instructions)
>  	 break;
>  
>        default:
> +         if (cur->num != 0 && cur->parents.is_empty()) {
> +            ip--;
> +            continue;
> +         }
> +
>           cur->instructions.push_tail(inst);
>  	 break;
>        }
> @@ -319,6 +324,12 @@ cfg_t::cfg_t(exec_list *instructions)
>  
>     cur->end_ip = ip - 1;
>  
> +   /* If the last block was empty (because it was unreachable) drop
> it. */
> +   if (cur->instructions.is_empty()) {
> +      cur->link.remove();
> +      num_blocks--;
> +   }
> +
>     make_block_array();
>  }
>  


More information about the mesa-dev mailing list