Mesa (master): i965: Clarify when we need to (re-)calculate live intervals.
Eric Anholt
anholt at kemper.freedesktop.org
Wed Jan 12 19:08:37 UTC 2011
Module: Mesa
Branch: master
Commit: e880a57a71bbd5152ed26367dcc7051f21c20981
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e880a57a71bbd5152ed26367dcc7051f21c20981
Author: Eric Anholt <eric at anholt.net>
Date: Wed Jan 12 10:10:01 2011 -0800
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.
---
src/mesa/drivers/dri/i965/brw_fs.cpp | 26 +++++++++++++++++----
src/mesa/drivers/dri/i965/brw_fs.h | 2 +
src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 4 +++
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index f4f9385..b618ee5 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -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();
}
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 00a0008..d213c62 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -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;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index bbb210c..078a349 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -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;
}
More information about the mesa-commit
mailing list