[Mesa-dev] [PATCH 2/4] i965/vec4: Improve CSE performance by expiring some available expressions.

Ian Romanick idr at freedesktop.org
Mon Jun 30 11:49:49 PDT 2014


On 06/25/2014 02:12 PM, Matt Turner wrote:
> Port of commit 5daf867f to the vec4 code.
> ---
>  src/mesa/drivers/dri/i965/brw_vec4_cse.cpp | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp b/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp
> index 33c7430..67fc58a 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp
> @@ -128,6 +128,7 @@ vec4_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
>  
>     void *cse_ctx = ralloc_context(NULL);
>  
> +   int ip = block->start_ip;
>     for (vec4_instruction *inst = (vec4_instruction *)block->start;
>          inst != block->end->next;
>          inst = (vec4_instruction *) inst->next) {
> @@ -198,6 +199,8 @@ vec4_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
>           aeb_entry *entry = (aeb_entry *)entry_node;
>  
>           for (int i = 0; i < 3; i++) {
> +            src_reg *src = &entry->generator->src[i];
> +
>              /* Kill all AEB entries that use the destination we just
>               * overwrote.
>               */
> @@ -207,8 +210,23 @@ vec4_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
>                 ralloc_free(entry);
>                 break;
>              }
> +
> +            /* Kill any AEB entries using registers that don't get reused any
> +             * more -- a sure sign they'll fail operands_match().
> +             */
> +            int last_reg_use = MAX2(MAX2(virtual_grf_end[src->reg * 4 + 0],
> +                                         virtual_grf_end[src->reg * 4 + 1]),
> +                                    MAX2(virtual_grf_end[src->reg * 4 + 2],
> +                                         virtual_grf_end[src->reg * 4 + 3]));
> +            if (src->file == GRF && last_reg_use < ip) {
> +               entry->remove();
> +               ralloc_free(entry);
> +               break;
> +            }
>           }
>        }
> +
> +      ip++;
>     }
>  
>     ralloc_free(cse_ctx);
> @@ -224,6 +242,8 @@ vec4_visitor::opt_cse()
>  {
>     bool progress = false;
>  
> +   calculate_live_intervals();
> +
>     cfg_t cfg(&instructions);

Does this also need a rebase on other patches you have pending?

>  
>     for (int b = 0; b < cfg.num_blocks; b++) {
> 



More information about the mesa-dev mailing list