Mesa (master): pan/bi: Only run DCE once
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Apr 3 17:07:00 UTC 2021
Module: Mesa
Branch: master
Commit: 93cdb072a82334c30acdb66936f09ecfaa0b5484
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=93cdb072a82334c30acdb66936f09ecfaa0b5484
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Tue Mar 2 20:22:26 2021 +0000
pan/bi: Only run DCE once
No more progress loop needed. I'm skeptical we really want a dataflow
approach long-term, though, this is annoyingly expensive.
No shader-db changes.
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9421>
---
src/panfrost/bifrost/bi_opt_dce.c | 29 ++++++++++++++---------------
src/panfrost/bifrost/bifrost_compile.c | 9 +--------
src/panfrost/bifrost/compiler.h | 2 +-
3 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/src/panfrost/bifrost/bi_opt_dce.c b/src/panfrost/bifrost/bi_opt_dce.c
index 39fc5d7ad6c..fbed0df4350 100644
--- a/src/panfrost/bifrost/bi_opt_dce.c
+++ b/src/panfrost/bifrost/bi_opt_dce.c
@@ -33,18 +33,22 @@
* encodings will result.)
*/
-bool
+void
bi_opt_dead_code_eliminate(bi_context *ctx, bool soft)
{
- bool progress = false;
unsigned temp_count = bi_max_temp(ctx);
bi_invalidate_liveness(ctx);
bi_compute_liveness(ctx);
- bi_foreach_block(ctx, _block) {
+ bi_foreach_block_rev(ctx, _block) {
bi_block *block = (bi_block *) _block;
- uint16_t *live = mem_dup(block->base.live_out, temp_count * sizeof(uint16_t));
+ uint16_t *live = rzalloc_array(_block, uint16_t, temp_count);
+
+ pan_foreach_successor(_block, succ) {
+ for (unsigned i = 0; i < temp_count; ++i)
+ live[i] |= succ->live_in[i];
+ }
bi_foreach_instr_in_block_safe_rev(block, ins) {
bool all_null = true;
@@ -52,24 +56,19 @@ bi_opt_dead_code_eliminate(bi_context *ctx, bool soft)
bi_foreach_dest(ins, d) {
unsigned index = bi_get_node(ins->dest[d]);
- if (index < temp_count && !(live[index] & bi_writemask(ins, d))) {
+ if (index < temp_count && !(live[index] & bi_writemask(ins, d)))
ins->dest[d] = bi_null();
- progress = true;
- }
all_null &= bi_is_null(ins->dest[d]);
}
- if (all_null && !soft && !bi_side_effects(ins->op)) {
+ if (all_null && !soft && !bi_side_effects(ins->op))
bi_remove_instruction(ins);
- progress = true;
- }
-
- bi_liveness_ins_update(live, ins, temp_count);
+ else
+ bi_liveness_ins_update(live, ins, temp_count);
}
- free(live);
+ ralloc_free(block->base.live_in);
+ block->base.live_in = live;
}
-
- return progress;
}
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 26ed1b53d1e..f662911fd96 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -3036,14 +3036,7 @@ bifrost_compile_shader_nir(nir_shader *nir,
/* Runs before copy prop */
bi_opt_push_ubo(ctx);
bi_opt_copy_prop(ctx);
-
- bool progress = false;
-
- do {
- progress = false;
-
- progress |= bi_opt_dead_code_eliminate(ctx, false);
- } while(progress);
+ bi_opt_dead_code_eliminate(ctx, false);
bi_foreach_block(ctx, _block) {
bi_block *block = (bi_block *) _block;
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index d082a09949d..d2b1d414ccd 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -745,7 +745,7 @@ void bi_print_shader(bi_context *ctx, FILE *fp);
/* BIR passes */
void bi_opt_copy_prop(bi_context *ctx);
-bool bi_opt_dead_code_eliminate(bi_context *ctx, bool soft);
+void bi_opt_dead_code_eliminate(bi_context *ctx, bool soft);
void bi_opt_push_ubo(bi_context *ctx);
void bi_schedule(bi_context *ctx);
void bi_assign_scoreboard(bi_context *ctx);
More information about the mesa-commit
mailing list