Mesa (master): nir/gcm: Move block choosing into a helper function
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Apr 20 04:38:56 UTC 2020
Module: Mesa
Branch: master
Commit: 5b1615fdb75659cb02fcbcd684046eabdb807930
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b1615fdb75659cb02fcbcd684046eabdb807930
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Tue Jan 17 18:38:38 2017 -0800
nir/gcm: Move block choosing into a helper function
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4636>
---
src/compiler/nir/nir_opt_gcm.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c
index 4d62e813f4b..375f9e71b57 100644
--- a/src/compiler/nir/nir_opt_gcm.c
+++ b/src/compiler/nir/nir_opt_gcm.c
@@ -266,6 +266,25 @@ gcm_schedule_early_instr(nir_instr *instr, struct gcm_state *state)
nir_foreach_src(instr, gcm_schedule_early_src, state);
}
+static nir_block *
+gcm_choose_block_for_instr(nir_instr *instr, nir_block *early_block,
+ nir_block *late_block, struct gcm_state *state)
+{
+ assert(nir_block_dominates(early_block, late_block));
+
+ nir_block *best = late_block;
+ for (nir_block *block = late_block; block != NULL; block = block->imm_dom) {
+ if (state->blocks[block->index].loop_depth <
+ state->blocks[best->index].loop_depth)
+ best = block;
+
+ if (block == early_block)
+ break;
+ }
+
+ return best;
+}
+
static void
gcm_schedule_late_instr(nir_instr *instr, struct gcm_state *state);
@@ -335,17 +354,8 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
* We now walk up the dominance tree and pick the lowest block that is
* as far outside loops as we can get.
*/
- assert(nir_block_dominates(early_block, lca));
- nir_block *best = lca;
- for (nir_block *block = lca; block != NULL; block = block->imm_dom) {
- if (state->blocks[block->index].loop_depth <
- state->blocks[best->index].loop_depth)
- best = block;
-
- if (block == early_block)
- break;
- }
- def->parent_instr->block = best;
+ def->parent_instr->block =
+ gcm_choose_block_for_instr(def->parent_instr, early_block, lca, state);
return true;
}
More information about the mesa-commit
mailing list