[Mesa-dev] [PATCH 08/19] i965/fs: Loop from 0 to inst->sources, not 0 to 3.
Matt Turner
mattst88 at gmail.com
Fri Apr 18 11:56:44 PDT 2014
---
src/mesa/drivers/dri/i965/brw_fs.cpp | 24 +++++++++++-----------
.../drivers/dri/i965/brw_fs_copy_propagation.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_fs_cse.cpp | 2 +-
.../dri/i965/brw_fs_dead_code_eliminate.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 2 +-
.../drivers/dri/i965/brw_fs_live_variables.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 6 +++---
.../drivers/dri/i965/brw_fs_register_coalesce.cpp | 2 +-
.../dri/i965/brw_fs_saturate_propagation.cpp | 2 +-
.../drivers/dri/i965/brw_schedule_instructions.cpp | 10 ++++-----
10 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 86eed27..e963ee8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1488,7 +1488,7 @@ fs_visitor::assign_curb_setup()
foreach_list(node, &this->instructions) {
fs_inst *inst = (fs_inst *)node;
- for (unsigned int i = 0; i < 3; i++) {
+ for (unsigned int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == UNIFORM) {
int uniform_nr = inst->src[i].reg + inst->src[i].reg_offset;
int constant_nr;
@@ -1686,7 +1686,7 @@ fs_visitor::split_virtual_grfs()
* the send is reading the whole thing.
*/
if (inst->is_send_from_grf()) {
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF) {
split_grf[inst->src[i].reg] = false;
}
@@ -1719,7 +1719,7 @@ fs_visitor::split_virtual_grfs()
inst->dst.reg_offset - 1);
inst->dst.reg_offset = 0;
}
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF &&
split_grf[inst->src[i].reg] &&
inst->src[i].reg_offset != 0) {
@@ -1754,7 +1754,7 @@ fs_visitor::compact_virtual_grfs()
if (inst->dst.file == GRF)
remap_table[inst->dst.reg] = 0;
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF)
remap_table[inst->src[i].reg] = 0;
}
@@ -1808,7 +1808,7 @@ fs_visitor::compact_virtual_grfs()
if (inst->dst.file == GRF)
inst->dst.reg = remap_table[inst->dst.reg];
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF)
inst->src[i].reg = remap_table[inst->src[i].reg];
}
@@ -1857,7 +1857,7 @@ fs_visitor::move_uniform_array_access_to_pull_constants()
foreach_list_safe(node, &this->instructions) {
fs_inst *inst = (fs_inst *)node;
- for (int i = 0 ; i < 3; i++) {
+ for (int i = 0 ; i < inst->sources; i++) {
if (inst->src[i].file != UNIFORM || !inst->src[i].reladdr)
continue;
@@ -1907,7 +1907,7 @@ fs_visitor::assign_constant_locations()
foreach_list(node, &this->instructions) {
fs_inst *inst = (fs_inst *) node;
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file != UNIFORM)
continue;
@@ -1978,7 +1978,7 @@ fs_visitor::demote_pull_constants()
foreach_list(node, &this->instructions) {
fs_inst *inst = (fs_inst *)node;
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file != UNIFORM)
continue;
@@ -2230,7 +2230,7 @@ fs_visitor::compute_to_mrf()
* MRF's source GRF that we wanted to rewrite, that stops us.
*/
bool interfered = false;
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < scan_inst->sources; i++) {
if (scan_inst->src[i].file == GRF &&
scan_inst->src[i].reg == inst->src[0].reg &&
scan_inst->src[i].reg_offset == inst->src[0].reg_offset) {
@@ -2369,7 +2369,7 @@ clear_deps_for_inst_src(fs_inst *inst, int dispatch_width, bool *deps,
!inst->force_sechalf);
/* Clear the flag for registers that actually got read (as expected). */
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
int grf;
if (inst->src[i].file == GRF) {
grf = inst->src[i].reg;
@@ -2727,7 +2727,7 @@ fs_visitor::dump_instruction(backend_instruction *be_inst)
}
fprintf(stderr, ":%s, ", brw_reg_type_letters(inst->dst.type));
- for (int i = 0; i < 3 && inst->src[i].file != BAD_FILE; i++) {
+ for (int i = 0; i < inst->sources && inst->src[i].file != BAD_FILE; i++) {
if (inst->src[i].negate)
fprintf(stderr, "-");
if (inst->src[i].abs)
@@ -2816,7 +2816,7 @@ fs_visitor::dump_instruction(backend_instruction *be_inst)
fprintf(stderr, ":%s", brw_reg_type_letters(inst->src[i].type));
}
- if (i < 2 && inst->src[i + 1].file != BAD_FILE)
+ if (i < inst->sources - 1 && inst->src[i + 1].file != BAD_FILE)
fprintf(stderr, ", ");
}
diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index a148c54..0580cbe 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -493,7 +493,7 @@ fs_visitor::opt_copy_propagate_local(void *copy_prop_ctx, bblock_t *block,
inst = (fs_inst *)inst->next) {
/* Try propagating into this instruction. */
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file != GRF)
continue;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
index ea610bd..94f657d 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
@@ -228,7 +228,7 @@ fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
}
}
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < entry->generator->sources; i++) {
fs_reg *src_reg = &entry->generator->src[i];
/* Kill all AEB entries that use the destination we just
diff --git a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
index dfeceb0..962d8c6 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
@@ -90,7 +90,7 @@ fs_visitor::dead_code_eliminate()
}
}
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF) {
int var = live_intervals->var_from_vgrf[inst->src[i].reg];
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index ff85171..38ba21c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1390,7 +1390,7 @@ fs_generator::generate_code(exec_list *instructions, FILE *dump_file)
}
}
- for (unsigned int i = 0; i < 3; i++) {
+ for (unsigned int i = 0; i < inst->sources; i++) {
src[i] = brw_reg_from_fs_reg(&inst->src[i]);
/* The accumulator result appears to get used for the
diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
index c7b1f25..93022e9 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
@@ -149,7 +149,7 @@ fs_live_variables::setup_def_use()
inst = (fs_inst *)inst->next) {
/* Set use[] for this instruction */
- for (unsigned int i = 0; i < 3; i++) {
+ for (unsigned int i = 0; i < inst->sources; i++) {
fs_reg reg = inst->src[i];
if (reg.file != GRF)
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 f2f158e..518a916 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -273,7 +273,7 @@ fs_visitor::setup_payload_interference(struct ra_graph *g,
* assign_curbe_setup(), and interpolation uses fixed hardware regs from
* the start (see interp_reg()).
*/
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == HW_REG &&
inst->src[i].fixed_hw_reg.file == BRW_GENERAL_REGISTER_FILE) {
int node_nr = inst->src[i].fixed_hw_reg.nr / reg_width;
@@ -583,7 +583,7 @@ fs_visitor::choose_spill_reg(struct ra_graph *g)
foreach_list(node, &this->instructions) {
fs_inst *inst = (fs_inst *)node;
- for (unsigned int i = 0; i < 3; i++) {
+ for (unsigned int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF) {
spill_costs[inst->src[i].reg] += loop_scale;
@@ -682,7 +682,7 @@ fs_visitor::spill_reg(int spill_reg)
foreach_list(node, &this->instructions) {
fs_inst *inst = (fs_inst *)node;
- for (unsigned int i = 0; i < 3; i++) {
+ for (unsigned int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF &&
inst->src[i].reg == spill_reg) {
int regs_read = inst->regs_read(this, i);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
index 13b678a..cb4ab57 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
@@ -192,7 +192,7 @@ fs_visitor::register_coalesce()
scan_inst->dst.reg = reg_to;
scan_inst->dst.reg_offset = reg_to_offset[i];
}
- for (int j = 0; j < 3; j++) {
+ for (int j = 0; j < scan_inst->sources; j++) {
if (scan_inst->src[j].file == GRF &&
scan_inst->src[j].reg == reg_from &&
scan_inst->src[j].reg_offset == i) {
diff --git a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
index 35e6774..1b3d3b7 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
@@ -70,7 +70,7 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t *block)
}
break;
}
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < scan_inst->sources; i++) {
if (scan_inst->src[i].file == GRF &&
scan_inst->src[i].reg == inst->src[0].reg &&
scan_inst->src[i].reg_offset == inst->src[0].reg_offset) {
diff --git a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
index 8cc6908..ccce117 100644
--- a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
+++ b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
@@ -505,7 +505,7 @@ fs_instruction_scheduler::count_remaining_grf_uses(backend_instruction *be)
if (inst->dst.file == GRF)
remaining_grf_uses[inst->dst.reg]++;
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file != GRF)
continue;
@@ -526,7 +526,7 @@ fs_instruction_scheduler::update_register_pressure(backend_instruction *be)
grf_active[inst->dst.reg] = true;
}
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF) {
remaining_grf_uses[inst->src[i].reg]--;
grf_active[inst->src[i].reg] = true;
@@ -547,7 +547,7 @@ fs_instruction_scheduler::get_register_pressure_benefit(backend_instruction *be)
benefit -= v->virtual_grf_sizes[inst->dst.reg];
}
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file != GRF)
continue;
@@ -783,7 +783,7 @@ fs_instruction_scheduler::calculate_deps()
add_barrier_deps(n);
/* read-after-write deps. */
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF) {
if (post_reg_alloc) {
for (int r = 0; r < reg_width * inst->regs_read(v, i); r++)
@@ -913,7 +913,7 @@ fs_instruction_scheduler::calculate_deps()
fs_inst *inst = (fs_inst *)n->inst;
/* write-after-read deps. */
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF) {
if (post_reg_alloc) {
for (int r = 0; r < reg_width * inst->regs_read(v, i); r++)
--
1.8.3.2
More information about the mesa-dev
mailing list