From b8f042c9bb0e1c6de684222d301084e5e2b17c3e Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 5 Feb 2021 17:58:46 -0500 Subject: [PATCH] pan/bi: Dead code eliminate per-channel We already track the full liveness so this is a trivial optimization, with an especial win for shaders reading only a subset of components of gl_FragCoord. More importantly, it's required for proper scheduling (in soft mode) when vectors are used and some (but not all components) are promoted to temporary registers. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bi_opt_dce.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/panfrost/bifrost/bi_opt_dce.c b/src/panfrost/bifrost/bi_opt_dce.c index 589198e4738..7feadc49605 100644 --- a/src/panfrost/bifrost/bi_opt_dce.c +++ b/src/panfrost/bifrost/bi_opt_dce.c @@ -46,8 +46,9 @@ bi_opt_dead_code_eliminate(bi_context *ctx, bi_block *block, bool soft) bi_foreach_instr_in_block_safe_rev(block, ins) { unsigned index = bi_get_node(ins->dest[0]); + bool index_live = (live[index] & bi_writemask(ins)); - if (index < temp_count && !live[index]) { + if (index < temp_count && !index_live) { if (soft || bi_side_effects(ins->op)) ins->dest[0] = bi_null(); else