i965/vec4: Track live ranges per-channel, not per vgrf.

Will be squashed with the next patch.

Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Matt Turner 2014-03-11 13:06:20 -07:00
parent 89ccd11eeb
commit dc0f5099fa
2 changed files with 41 additions and 14 deletions

View File

@ -888,7 +888,10 @@ vec4_visitor::opt_register_coalesce()
/* Can't coalesce this GRF if someone else was going to /* Can't coalesce this GRF if someone else was going to
* read it later. * read it later.
*/ */
if (this->virtual_grf_end[inst->src[0].reg] > ip) 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)
continue; continue;
/* We need to check interference with the final destination between this /* We need to check interference with the final destination between this

View File

@ -203,14 +203,14 @@ vec4_visitor::calculate_live_intervals()
if (this->live_intervals_valid) if (this->live_intervals_valid)
return; return;
int *start = ralloc_array(mem_ctx, int, this->virtual_grf_count); int *start = ralloc_array(mem_ctx, int, this->virtual_grf_count * 4);
int *end = ralloc_array(mem_ctx, int, this->virtual_grf_count); int *end = ralloc_array(mem_ctx, int, this->virtual_grf_count * 4);
ralloc_free(this->virtual_grf_start); ralloc_free(this->virtual_grf_start);
ralloc_free(this->virtual_grf_end); ralloc_free(this->virtual_grf_end);
this->virtual_grf_start = start; this->virtual_grf_start = start;
this->virtual_grf_end = end; this->virtual_grf_end = end;
for (int i = 0; i < this->virtual_grf_count; i++) { for (int i = 0; i < this->virtual_grf_count * 4; i++) {
start[i] = MAX_INSTRUCTION; start[i] = MAX_INSTRUCTION;
end[i] = -1; end[i] = -1;
} }
@ -226,16 +226,24 @@ vec4_visitor::calculate_live_intervals()
if (inst->src[i].file == GRF) { if (inst->src[i].file == GRF) {
int reg = inst->src[i].reg; int reg = inst->src[i].reg;
start[reg] = MIN2(start[reg], ip); for (int j = 0; j < 4; j++) {
end[reg] = ip; int c = BRW_GET_SWZ(inst->src[i].swizzle, j);
start[reg * 4 + c] = MIN2(start[reg * 4 + c], ip);
end[reg * 4 + c] = ip;
}
} }
} }
if (inst->dst.file == GRF) { if (inst->dst.file == GRF) {
int reg = inst->dst.reg; int reg = inst->dst.reg;
start[reg] = MIN2(start[reg], ip); for (int c = 0; c < 4; c++) {
end[reg] = ip; if (inst->dst.writemask & (1 << c)) {
start[reg * 4 + c] = MIN2(start[reg * 4 + c], ip);
end[reg * 4 + c] = ip;
}
}
} }
ip++; ip++;
@ -252,13 +260,13 @@ vec4_visitor::calculate_live_intervals()
for (int b = 0; b < cfg.num_blocks; b++) { for (int b = 0; b < cfg.num_blocks; b++) {
for (int i = 0; i < livevars.num_vars; i++) { for (int i = 0; i < livevars.num_vars; i++) {
if (BITSET_TEST(livevars.bd[b].livein, i)) { if (BITSET_TEST(livevars.bd[b].livein, i)) {
start[i / 4] = MIN2(start[i / 4], cfg.blocks[b]->start_ip); start[i] = MIN2(start[i], cfg.blocks[b]->start_ip);
end[i / 4] = MAX2(end[i / 4], cfg.blocks[b]->start_ip); end[i] = MAX2(end[i], cfg.blocks[b]->start_ip);
} }
if (BITSET_TEST(livevars.bd[b].liveout, i)) { if (BITSET_TEST(livevars.bd[b].liveout, i)) {
start[i / 4] = MIN2(start[i / 4], cfg.blocks[b]->end_ip); start[i] = MIN2(start[i], cfg.blocks[b]->end_ip);
end[i / 4] = MAX2(end[i / 4], cfg.blocks[b]->end_ip); end[i] = MAX2(end[i], cfg.blocks[b]->end_ip);
} }
} }
} }
@ -275,6 +283,22 @@ vec4_visitor::invalidate_live_intervals()
bool bool
vec4_visitor::virtual_grf_interferes(int a, int b) vec4_visitor::virtual_grf_interferes(int a, int b)
{ {
return !(virtual_grf_end[a] <= virtual_grf_start[b] || int start_a = MIN2(MIN2(virtual_grf_start[a * 4 + 0],
virtual_grf_end[b] <= virtual_grf_start[a]); 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);
} }