[Mesa-dev] [PATCH 3/3] i965/vs: Refactor opt_copy_propagation's current value tracking code.
Kenneth Graunke
kenneth at whitecape.org
Fri Dec 23 20:57:48 PST 2011
Having the direct copy case short-circuit the loop doesn't make sense.
In both cases, we need to update the destination's current value, as
well as the current value of any register that pointed to our
destination. The only difference is whether or not we know our
destination's current value.
By removing the "continue", we can remove the duplicated block
introduced in the previous commit and share code.
Cc: Eric Anholt <eric at anholt.net>
Cc: Matt Turner <mattst88 at gmail.com>
Cc: Christopher James Halse Rogers <chalserogers at gmail.com>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
.../drivers/dri/i965/brw_vec4_copy_propagation.cpp | 40 +++++--------------
1 files changed, 11 insertions(+), 29 deletions(-)
Sorry this is hard to follow...
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index 3e24903..08d8f5b 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -297,44 +297,26 @@ vec4_visitor::opt_copy_propagation()
}
/* Track available source registers. */
- if (is_direct_copy(inst)) {
- int reg = virtual_grf_reg_map[inst->dst.reg] + inst->dst.reg_offset;
- for (int i = 0; i < 4; i++) {
- if (inst->dst.writemask & (1 << i)) {
- cur_value[reg][i] = &inst->src[0];
- }
- }
+ const int reg = virtual_grf_reg_map[inst->dst.reg] + inst->dst.reg_offset;
- /* For any updated channels, clear tracking of them as a source. */
- for (int i = 0; i < virtual_grf_reg_count; i++) {
- for (int j = 0; j < 4; j++) {
- if (inst->dst.writemask & (1 << j) &&
- cur_value[i][j] &&
- cur_value[i][j]->file == GRF &&
- cur_value[i][j]->reg == inst->dst.reg &&
- cur_value[i][j]->reg_offset == inst->dst.reg_offset) {
- cur_value[i][j] = NULL;
- }
- }
+ /* Update our destination's current channel values. For a direct copy,
+ * the value is the newly propagated source. Otherwise, we don't know
+ * the new value, so clear it.
+ */
+ bool direct_copy = is_direct_copy(inst);
+ for (int i = 0; i < 4; i++) {
+ if (inst->dst.writemask & (1 << i)) {
+ cur_value[reg][i] = direct_copy ? &inst->src[0] : NULL;
}
-
- continue;
}
- /* For any updated channels, clear tracking of them as a source
- * or destination.
+ /* Clear the records for any registers whose current value came from
+ * our destination's updated channels, as the two are no longer equal.
*/
if (inst->dst.file == GRF) {
if (inst->dst.reladdr)
memset(cur_value, 0, sizeof(cur_value));
else {
- int reg = virtual_grf_reg_map[inst->dst.reg] + inst->dst.reg_offset;
-
- for (int i = 0; i < 4; i++) {
- if (inst->dst.writemask & (1 << i))
- cur_value[reg][i] = NULL;
- }
-
for (int i = 0; i < virtual_grf_reg_count; i++) {
for (int j = 0; j < 4; j++) {
if (inst->dst.writemask & (1 << j) &&
--
1.7.7.3
More information about the mesa-dev
mailing list