[Mesa-dev] [RFC 5/5] nir/gcm: Add a real concept of "progress"
Jason Ekstrand
jason at jlekstrand.net
Sat Jan 14 22:37:41 UTC 2017
Now that the GCM pass is more concervative and only moves instructions
to different blocks when it's advantageous to do so, we can have a
proper notion of what it means to make progress.
---
src/compiler/nir/nir_opt_gcm.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c
index eb1f200..0b839ac 100644
--- a/src/compiler/nir/nir_opt_gcm.c
+++ b/src/compiler/nir/nir_opt_gcm.c
@@ -67,6 +67,8 @@ struct gcm_state {
nir_function_impl *impl;
nir_instr *instr;
+ bool progress;
+
/* The list of non-pinned instructions. As we do the late scheduling,
* we pull non-pinned instructions out of their blocks and place them in
* this list. This saves us from having linked-list problems when we go
@@ -381,6 +383,10 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
if (block == early_block)
break;
}
+
+ if (def->parent_instr->block != best)
+ state->progress = true;
+
def->parent_instr->block = best;
return true;
@@ -507,6 +513,7 @@ opt_gcm_impl(nir_function_impl *impl, bool value_number)
state.impl = impl;
state.instr = NULL;
+ state.progress = false;
exec_list_make_empty(&state.instrs);
state.blocks = rzalloc_array(NULL, struct gcm_block_info, impl->num_blocks);
@@ -520,13 +527,12 @@ opt_gcm_impl(nir_function_impl *impl, bool value_number)
state.instr_infos =
rzalloc_array(NULL, struct gcm_instr_info, state.num_instrs);
- bool progress = false;
if (value_number) {
struct set *gvn_set = nir_instr_set_create(NULL);
foreach_list_typed_safe(nir_instr, instr, node, &state.instrs) {
if (nir_instr_set_add_or_rewrite(gvn_set, instr)) {
nir_instr_remove(instr);
- progress = true;
+ state.progress = true;
}
}
nir_instr_set_destroy(gvn_set);
@@ -549,7 +555,7 @@ opt_gcm_impl(nir_function_impl *impl, bool value_number)
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
- return progress;
+ return state.progress;
}
bool
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list