i965: Clarify when we need to (re-)calculate live intervals.

The ad-hoc placement of recalculation somewhere between when they got
invalidated and when they were next needed was confusing.  This should
clarify what's going on here.
This commit is contained in:
Eric Anholt 2011-01-12 10:10:01 -08:00
parent c60cb25bfb
commit e880a57a71
3 changed files with 27 additions and 5 deletions

View File

@ -2727,6 +2727,9 @@ fs_visitor::calculate_live_intervals()
int loop_start = 0;
int bb_header_ip = 0;
if (this->live_intervals_valid)
return;
for (int i = 0; i < num_vars; i++) {
def[i] = 1 << 30;
use[i] = -1;
@ -2806,6 +2809,8 @@ fs_visitor::calculate_live_intervals()
talloc_free(this->virtual_grf_use);
this->virtual_grf_def = def;
this->virtual_grf_use = use;
this->live_intervals_valid = true;
}
/**
@ -2821,6 +2826,8 @@ fs_visitor::propagate_constants()
{
bool progress = false;
calculate_live_intervals();
foreach_iter(exec_list_iterator, iter, this->instructions) {
fs_inst *inst = (fs_inst *)iter.get();
@ -2878,6 +2885,7 @@ fs_visitor::propagate_constants()
/* Fit this constant in by commuting the operands */
scan_inst->src[0] = scan_inst->src[1];
scan_inst->src[1] = inst->src[0];
progress = true;
}
break;
case BRW_OPCODE_CMP:
@ -2898,6 +2906,9 @@ fs_visitor::propagate_constants()
}
}
if (progress)
this->live_intervals_valid = false;
return progress;
}
/**
@ -2912,6 +2923,8 @@ fs_visitor::dead_code_eliminate()
bool progress = false;
int pc = 0;
calculate_live_intervals();
foreach_iter(exec_list_iterator, iter, this->instructions) {
fs_inst *inst = (fs_inst *)iter.get();
@ -2923,6 +2936,9 @@ fs_visitor::dead_code_eliminate()
pc++;
}
if (progress)
live_intervals_valid = false;
return progress;
}
@ -3019,6 +3035,9 @@ fs_visitor::register_coalesce()
progress = true;
}
if (progress)
live_intervals_valid = false;
return progress;
}
@ -3029,6 +3048,8 @@ fs_visitor::compute_to_mrf()
bool progress = false;
int next_ip = 0;
calculate_live_intervals();
foreach_iter(exec_list_iterator, iter, this->instructions) {
fs_inst *inst = (fs_inst *)iter.get();
@ -3628,10 +3649,8 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c)
progress = v.remove_duplicate_mrf_writes() || progress;
v.calculate_live_intervals();
progress = v.propagate_constants() || progress;
progress = v.register_coalesce() || progress;
v.calculate_live_intervals();
progress = v.compute_to_mrf() || progress;
progress = v.dead_code_eliminate() || progress;
} while (progress);
@ -3642,7 +3661,6 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c)
for (int i = 1; i < virtual_grf_count; i++) {
v.spill_reg(i);
}
v.calculate_live_intervals();
}
if (0)
@ -3651,8 +3669,6 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c)
while (!v.assign_regs()) {
if (v.fail)
break;
v.calculate_live_intervals();
}
}
}

View File

@ -378,6 +378,7 @@ public:
this->virtual_grf_array_size = 0;
this->virtual_grf_def = NULL;
this->virtual_grf_use = NULL;
this->live_intervals_valid = false;
this->kill_emitted = false;
}
@ -479,6 +480,7 @@ public:
int virtual_grf_array_size;
int *virtual_grf_def;
int *virtual_grf_use;
bool live_intervals_valid;
struct hash_table *variable_ht;
ir_variable *frag_color, *frag_data, *frag_depth;

View File

@ -94,6 +94,8 @@ fs_visitor::assign_regs()
int class_count = 0;
int aligned_pair_class = -1;
calculate_live_intervals();
/* Set up the register classes.
*
* The base registers store a scalar value. For texture samples,
@ -416,4 +418,6 @@ fs_visitor::spill_reg(int spill_reg)
}
}
}
this->live_intervals_valid = false;
}