mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
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 <mattst88@gmail.com>
This commit is contained in:
parent
eddb87402e
commit
e6e655ef76
4 changed files with 31 additions and 29 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue