From 7bd5856cc62bc56edb8a5abe191ad94a97ee88f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 20 Apr 2026 18:52:52 -0400 Subject: [PATCH] nir/opt_dce: factor out dead instruction removal into a helper Reviewed-by: Georg Lehmann Part-of: --- src/compiler/nir/nir_opt_dce.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/compiler/nir/nir_opt_dce.c b/src/compiler/nir/nir_opt_dce.c index 897142c7464..a24877bf272 100644 --- a/src/compiler/nir/nir_opt_dce.c +++ b/src/compiler/nir/nir_opt_dce.c @@ -111,6 +111,13 @@ struct loop_state { nir_block *preheader; }; +static void +remove_instr(nir_instr *instr, struct exec_list *dead_instrs) +{ + nir_instr_remove(instr); + exec_list_push_tail(dead_instrs, &instr->node); +} + static bool dce_block(nir_block *block, BITSET_WORD *defs_live, struct loop_state *loop, struct exec_list *dead_instrs) @@ -136,8 +143,7 @@ dce_block(nir_block *block, BITSET_WORD *defs_live, struct loop_state *loop, if (loop->preheader) { instr->pass_flags = live; } else if (!live) { - nir_instr_remove(instr); - exec_list_push_tail(dead_instrs, &instr->node); + remove_instr(instr, dead_instrs); progress = true; } } @@ -204,8 +210,7 @@ dce_cf_list(struct exec_list *cf_list, BITSET_WORD *defs_live, nir_foreach_block_in_cf_node(block, cf_node) { nir_foreach_instr_safe(instr, block) { if (!instr->pass_flags) { - nir_instr_remove(instr); - exec_list_push_tail(dead_instrs, &instr->node); + remove_instr(instr, dead_instrs); progress = true; } }