From: Francisco Jerez Date: Wed, 18 Mar 2015 18:49:43 +0000 (+0200) Subject: i965/vec4: Define helpers to calculate the common live interval of a range of variables. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e6e655ef76bb22193b31af2841cb50fda0c39461;p=mesa.git i965/vec4: Define helpers to calculate the common live interval of a range of variables. These will be especially useful when we start keeping track of liveness information for each subregister. Reviewed-by: Matt Turner --- diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 2c4a3d6f2da..918519c9394 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -25,6 +25,7 @@ #include "brw_fs.h" #include "brw_cfg.h" #include "brw_vs.h" +#include "brw_vec4_live_variables.h" #include "brw_dead_control_flow.h" extern "C" { @@ -981,10 +982,7 @@ vec4_visitor::opt_register_coalesce() /* Can't coalesce this GRF if someone else was going to * read it later. */ - if (this->virtual_grf_end[inst->src[0].reg * 4 + 0] > ip || - this->virtual_grf_end[inst->src[0].reg * 4 + 1] > ip || - this->virtual_grf_end[inst->src[0].reg * 4 + 2] > ip || - this->virtual_grf_end[inst->src[0].reg * 4 + 3] > ip) + if (var_range_end(var_from_reg(alloc, inst->src[0]), 4) > ip) continue; /* We need to check interference with the final destination between this diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 2fd2f29c4be..33297aea827 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -201,6 +201,8 @@ public: bool opt_vector_float(); bool opt_reduce_swizzle(); bool dead_code_eliminate(); + int var_range_start(unsigned v, unsigned n) const; + int var_range_end(unsigned v, unsigned n) const; bool virtual_grf_interferes(int a, int b); bool opt_copy_propagation(bool do_constant_prop = true); bool opt_cse_local(bblock_t *block); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp b/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp index 489248ee351..100e511a56c 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp @@ -232,13 +232,7 @@ vec4_visitor::opt_cse_local(bblock_t *block) * more -- a sure sign they'll fail operands_match(). */ if (src->file == GRF) { - assert((unsigned)(src->reg * 4 + 3) < (alloc.count * 4)); - - 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 (last_reg_use < ip) { + if (var_range_end(var_from_reg(alloc, *src), 4) < ip) { entry->remove(); ralloc_free(entry); break; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp index 5b2e13c144b..66beb21397b 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp @@ -300,25 +300,33 @@ vec4_visitor::invalidate_live_intervals() live_intervals = NULL; } +int +vec4_visitor::var_range_start(unsigned v, unsigned n) const +{ + int start = INT_MAX; + + for (unsigned i = 0; i < n; i++) + start = MIN2(start, virtual_grf_start[v + i]); + + return start; +} + +int +vec4_visitor::var_range_end(unsigned v, unsigned n) const +{ + int end = INT_MIN; + + for (unsigned i = 0; i < n; i++) + end = MAX2(end, virtual_grf_end[v + i]); + + return end; +} + bool vec4_visitor::virtual_grf_interferes(int a, int b) { - int start_a = MIN2(MIN2(virtual_grf_start[a * 4 + 0], - virtual_grf_start[a * 4 + 1]), - MIN2(virtual_grf_start[a * 4 + 2], - virtual_grf_start[a * 4 + 3])); - int start_b = MIN2(MIN2(virtual_grf_start[b * 4 + 0], - virtual_grf_start[b * 4 + 1]), - MIN2(virtual_grf_start[b * 4 + 2], - virtual_grf_start[b * 4 + 3])); - int end_a = MAX2(MAX2(virtual_grf_end[a * 4 + 0], - virtual_grf_end[a * 4 + 1]), - MAX2(virtual_grf_end[a * 4 + 2], - virtual_grf_end[a * 4 + 3])); - int end_b = MAX2(MAX2(virtual_grf_end[b * 4 + 0], - virtual_grf_end[b * 4 + 1]), - MAX2(virtual_grf_end[b * 4 + 2], - virtual_grf_end[b * 4 + 3])); - return !(end_a <= start_b || - end_b <= start_a); + return !((var_range_end(4 * a, 4) <= + var_range_start(4 * b, 4)) || + (var_range_end(4 * b, 4) <= + var_range_start(4 * a, 4))); }