[Mesa-dev] [PATCH 09/11] i965/vec4: Define helpers to calculate the common live interval of a range of variables.
Francisco Jerez
currojerez at riseup.net
Fri Mar 20 11:05:29 PDT 2015
Matt Turner <mattst88 at gmail.com> writes:
> On Fri, Mar 20, 2015 at 7:50 AM, Francisco Jerez <currojerez at riseup.net> wrote:
>> These will be especially useful when we start keeping track of
>> liveness information for each subregister.
>> ---
>> src/mesa/drivers/dri/i965/brw_vec4.cpp | 6 +--
>> src/mesa/drivers/dri/i965/brw_vec4.h | 2 +
>> src/mesa/drivers/dri/i965/brw_vec4_cse.cpp | 8 +---
>> .../drivers/dri/i965/brw_vec4_live_variables.cpp | 44 +++++++++++++---------
>> 4 files changed, 31 insertions(+), 29 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
>> index ce02fe3..30bbb9b 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" {
>> @@ -1001,10 +1002,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 50b9921..f1b3000 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 var, unsigned n) const;
>> + int var_range_end(unsigned var, 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 d7fb452..9147c3c 100644
>> --- a/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp
>> @@ -234,13 +234,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 5b2e13c..4b87af2 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 var, unsigned n) const
>> +{
>> + int start = INT_MAX;
>> +
>> + for (unsigned i = 0; i < n; ++i)
>
> ++i, the mark of a C++ programmer :)
>
>> + start = MIN2(start, virtual_grf_start[v + i]);
>
> v -> var
>
Oops, I squashed the fix into PATCH 10 by mistake, I'll fix that.
Thanks!
>> +
>> + return start;
>> +}
>> +
>> +int
>> +vec4_visitor::var_range_end(unsigned var, unsigned n) const
>> +{
>> + int end = INT_MIN;
>> +
>> + for (unsigned i = 0; i < n; ++i)
>> + end = MAX2(end, virtual_grf_end[var + 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 !((virtual_grf_range_end(4 * a, 4) <=
>> + virtual_grf_range_start(4 * b, 4)) ||
>> + (virtual_grf_range_end(4 * b, 4) <=
>> + virtual_grf_range_start(4 * a, 4)));
>> }
>> --
>> 2.1.3
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150320/548de9a1/attachment.sig>
More information about the mesa-dev
mailing list