diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 9fef5b1f71d..d9757ec1b66 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -2003,7 +2003,7 @@ nir_function_impl_lower_instructions(nir_function_impl *impl, nir_if_rewrite_condition(use_src->parent_if, new_src); if (nir_ssa_def_is_unused(old_def)) { - iter = nir_instr_remove(instr); + iter = nir_instr_remove_and_dce(instr); } else { iter = nir_after_instr(instr); } @@ -2017,7 +2017,7 @@ nir_function_impl_lower_instructions(nir_function_impl *impl, if (new_def == NIR_LOWER_INSTR_PROGRESS_REPLACE) { /* Only instructions without a return value can be removed like this */ assert(!old_def); - iter = nir_instr_remove(instr); + iter = nir_instr_remove_and_dce(instr); progress = true; } else iter = nir_after_instr(instr); diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index d45c5505e68..5d123ab76f4 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4314,6 +4314,10 @@ typedef nir_ssa_def *(*nir_lower_instr_cb)(struct nir_builder *, * will be removed. If new instructions are added, the lowering callback will * also be called on them in case multiple lowerings are required. * + * If the callback indicates that the original instruction is replaced (either + * through a new SSA def or NIR_LOWER_INSTR_PROGRESS_REPLACE), then the + * instruction is removed along with any now-dead SSA defs it used. + * * The metadata for the nir_function_impl will also be updated. If any blocks * are added (they cannot be removed), dominance and block indices will be * invalidated.