From bef0601d51a95f0032ec63f708bba523db4c9325 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 19 Mar 2024 08:28:55 -0500 Subject: [PATCH] nir/lower_reg: Remove dead reg_decl intrinsics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For any reg we can lower, we remove it whenever we remove the last read or write. For regs that aren't used at all, however, there are no reads or writes so there's nothing to trigger the removal. Instead, we need to do it in setup_reg. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir_lower_reg_intrinsics_to_ssa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/nir/nir_lower_reg_intrinsics_to_ssa.c b/src/compiler/nir/nir_lower_reg_intrinsics_to_ssa.c index b844f4e5b82..fd1305ff464 100644 --- a/src/compiler/nir/nir_lower_reg_intrinsics_to_ssa.c +++ b/src/compiler/nir/nir_lower_reg_intrinsics_to_ssa.c @@ -36,6 +36,11 @@ struct regs_to_ssa_state { static void setup_reg(nir_intrinsic_instr *decl, struct regs_to_ssa_state *state) { + if (nir_def_is_unused(&decl->def)) { + nir_instr_remove(&decl->instr); + return; + } + assert(state->values[decl->def.index] == NULL); if (!should_lower_reg(decl)) return;