[Mesa-dev] [PATCH 2/2] i965/fs: dump some extra lowerings/optimizations on optimize
Alejandro PiƱeiro
apinheiro at igalia.com
Tue May 23 10:52:53 UTC 2017
Specifically, assign_constant_locations, lower_constant_loads and
split_virtual_grfs. For split and assign we assume that the lowering
will result on changes, as it uses to be the case, to avoid adding
progress checks there.
---
I added them because on my wip code I was getting some strange
assembly coming from one of those optimizations, and wanted to
know which one.
src/intel/compiler/brw_fs.cpp | 29 +++++++++++++++++------------
src/intel/compiler/brw_fs.h | 6 +++---
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 382a0fe..2a63449 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -1658,7 +1658,7 @@ fs_visitor::assign_gs_urb_setup()
* contiguous sets of GRFs. If we split, we'll end up with reduced
* live intervals and better dead code elimination and coalescing.
*/
-void
+bool
fs_visitor::split_virtual_grfs()
{
/* Compact the register file so we eliminate dead vgrfs. This
@@ -1775,6 +1775,8 @@ fs_visitor::split_virtual_grfs()
}
}
invalidate_live_intervals();
+
+ return true;
}
/**
@@ -1914,12 +1916,12 @@ set_push_pull_constant_loc(unsigned uniform, int *chunk_start,
* So, this will push some of them out to the pull constant buffer and
* update the program to load them.
*/
-void
+bool
fs_visitor::assign_constant_locations()
{
/* Only the first compile gets to decide on locations. */
if (dispatch_width != min_dispatch_width)
- return;
+ return false;
bool is_live[uniforms];
memset(is_live, 0, sizeof(is_live));
@@ -2087,16 +2089,19 @@ fs_visitor::assign_constant_locations()
if (stage == MESA_SHADER_COMPUTE)
brw_cs_prog_data(stage_prog_data)->thread_local_id_index =
new_thread_local_id_index;
+
+ return true;
}
/**
* Replace UNIFORM register file access with either UNIFORM_PULL_CONSTANT_LOAD
* or VARYING_PULL_CONSTANT_LOAD instructions which load values into VGRFs.
*/
-void
+bool
fs_visitor::lower_constant_loads()
{
const unsigned index = stage_prog_data->binding_table.pull_constants_start;
+ bool progress = false;
foreach_block_and_inst_safe (block, fs_inst, inst, cfg) {
/* Set up the annotation tracking for new generated instructions. */
@@ -2137,6 +2142,7 @@ fs_visitor::lower_constant_loads()
inst->src[i].offset % 4;
brw_mark_surface_used(prog_data, index);
+ progress = true;
}
if (inst->opcode == SHADER_OPCODE_MOV_INDIRECT &&
@@ -2158,9 +2164,12 @@ fs_visitor::lower_constant_loads()
inst->remove(block);
brw_mark_surface_used(prog_data, index);
+ progress = true;
}
}
invalidate_live_intervals();
+
+ return progress;
}
bool
@@ -5650,14 +5659,6 @@ fs_visitor::optimize()
*/
bld = fs_builder(this, 64);
- assign_constant_locations();
- lower_constant_loads();
-
- validate();
-
- split_virtual_grfs();
- validate();
-
#define OPT(pass, args...) ({ \
pass_num++; \
bool this_progress = pass(args); \
@@ -5680,6 +5681,10 @@ fs_visitor::optimize()
int iteration = 0;
int pass_num = 0;
+ OPT(assign_constant_locations);
+ OPT(lower_constant_loads);
+ OPT(split_virtual_grfs);
+
OPT(opt_drop_redundant_mov_to_flags);
do {
diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h
index 6c8c027..dc6cb6e 100644
--- a/src/intel/compiler/brw_fs.h
+++ b/src/intel/compiler/brw_fs.h
@@ -122,10 +122,10 @@ public:
int first_payload_node);
int choose_spill_reg(struct ra_graph *g);
void spill_reg(int spill_reg);
- void split_virtual_grfs();
+ bool split_virtual_grfs();
bool compact_virtual_grfs();
- void assign_constant_locations();
- void lower_constant_loads();
+ bool assign_constant_locations();
+ bool lower_constant_loads();
void invalidate_live_intervals();
void calculate_live_intervals();
void calculate_register_pressure();
--
2.9.3
More information about the mesa-dev
mailing list