From 75a721f3a8a5108e95eecff4c214801829652e6d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 21 Jul 2022 15:40:05 -0400 Subject: [PATCH] pan/bi: Don't remove dests in DCE Removing dests without removing instructions only makes sense for certain pseudo-instructions, but it makes the IR needlessly complicated for all instructions. There's no real reason to do so, we can signal this in a different way instead. No shader-db changes. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_opt_dce.c | 10 +++++----- src/panfrost/bifrost/bi_ra.c | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/panfrost/bifrost/bi_opt_dce.c b/src/panfrost/bifrost/bi_opt_dce.c index 24c43cae4b6..84ea9882c42 100644 --- a/src/panfrost/bifrost/bi_opt_dce.c +++ b/src/panfrost/bifrost/bi_opt_dce.c @@ -46,8 +46,6 @@ bi_opt_dead_code_eliminate(bi_context *ctx) bool all_null = true; bi_foreach_dest(ins, d) { - unsigned index = bi_get_node(ins->dest[d]); - /* Destination required */ if (ins->op == BI_OPCODE_AXCHG_I32 || ins->op == BI_OPCODE_ACMPXCHG_I32 || @@ -58,10 +56,12 @@ bi_opt_dead_code_eliminate(bi_context *ctx) ins->op == BI_OPCODE_ZS_EMIT) continue; - if (index < temp_count && !(live[index] & bi_writemask(ins, d))) - ins->dest[d] = bi_null(); + unsigned index = bi_get_node(ins->dest[d]); - all_null &= bi_is_null(ins->dest[d]); + if (index >= temp_count) + all_null = false; + else if (live[index] & bi_writemask(ins, d)) + all_null = false; } if (all_null && !bi_side_effects(ins)) diff --git a/src/panfrost/bifrost/bi_ra.c b/src/panfrost/bifrost/bi_ra.c index e43f5ec2406..36aaa738e52 100644 --- a/src/panfrost/bifrost/bi_ra.c +++ b/src/panfrost/bifrost/bi_ra.c @@ -718,9 +718,8 @@ bi_lower_vector(bi_context *ctx) bi_index src = I->src[0]; assert(src.offset == 0); - for (unsigned i = 0; i < I->nr_dests; ++i) { - if (bi_is_null(I->dest[i])) - continue; + bi_foreach_dest(I, i) { + assert(!bi_is_null(I->dest[i])); src.offset = i; bi_mov_i32_to(&b, I->dest[i], src);