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@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9421>
This commit is contained in:
parent
b7a339bc97
commit
93cdb072a8
|
@ -33,18 +33,22 @@
|
||||||
* encodings will result.)
|
* encodings will result.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
void
|
||||||
bi_opt_dead_code_eliminate(bi_context *ctx, bool soft)
|
bi_opt_dead_code_eliminate(bi_context *ctx, bool soft)
|
||||||
{
|
{
|
||||||
bool progress = false;
|
|
||||||
unsigned temp_count = bi_max_temp(ctx);
|
unsigned temp_count = bi_max_temp(ctx);
|
||||||
|
|
||||||
bi_invalidate_liveness(ctx);
|
bi_invalidate_liveness(ctx);
|
||||||
bi_compute_liveness(ctx);
|
bi_compute_liveness(ctx);
|
||||||
|
|
||||||
bi_foreach_block(ctx, _block) {
|
bi_foreach_block_rev(ctx, _block) {
|
||||||
bi_block *block = (bi_block *) _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) {
|
bi_foreach_instr_in_block_safe_rev(block, ins) {
|
||||||
bool all_null = true;
|
bool all_null = true;
|
||||||
|
@ -52,24 +56,19 @@ bi_opt_dead_code_eliminate(bi_context *ctx, bool soft)
|
||||||
bi_foreach_dest(ins, d) {
|
bi_foreach_dest(ins, d) {
|
||||||
unsigned index = bi_get_node(ins->dest[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();
|
ins->dest[d] = bi_null();
|
||||||
progress = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
all_null &= bi_is_null(ins->dest[d]);
|
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);
|
bi_remove_instruction(ins);
|
||||||
progress = true;
|
else
|
||||||
}
|
bi_liveness_ins_update(live, ins, temp_count);
|
||||||
|
|
||||||
bi_liveness_ins_update(live, ins, temp_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(live);
|
ralloc_free(block->base.live_in);
|
||||||
|
block->base.live_in = live;
|
||||||
}
|
}
|
||||||
|
|
||||||
return progress;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3036,14 +3036,7 @@ bifrost_compile_shader_nir(nir_shader *nir,
|
||||||
/* Runs before copy prop */
|
/* Runs before copy prop */
|
||||||
bi_opt_push_ubo(ctx);
|
bi_opt_push_ubo(ctx);
|
||||||
bi_opt_copy_prop(ctx);
|
bi_opt_copy_prop(ctx);
|
||||||
|
bi_opt_dead_code_eliminate(ctx, false);
|
||||||
bool progress = false;
|
|
||||||
|
|
||||||
do {
|
|
||||||
progress = false;
|
|
||||||
|
|
||||||
progress |= bi_opt_dead_code_eliminate(ctx, false);
|
|
||||||
} while(progress);
|
|
||||||
|
|
||||||
bi_foreach_block(ctx, _block) {
|
bi_foreach_block(ctx, _block) {
|
||||||
bi_block *block = (bi_block *) _block;
|
bi_block *block = (bi_block *) _block;
|
||||||
|
|
|
@ -745,7 +745,7 @@ void bi_print_shader(bi_context *ctx, FILE *fp);
|
||||||
/* BIR passes */
|
/* BIR passes */
|
||||||
|
|
||||||
void bi_opt_copy_prop(bi_context *ctx);
|
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_opt_push_ubo(bi_context *ctx);
|
||||||
void bi_schedule(bi_context *ctx);
|
void bi_schedule(bi_context *ctx);
|
||||||
void bi_assign_scoreboard(bi_context *ctx);
|
void bi_assign_scoreboard(bi_context *ctx);
|
||||||
|
|
Loading…
Reference in New Issue