nir/from_ssa: Use nir_foreach_def() instead of nir_foreach_dest()

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>
This commit is contained in:
Faith Ekstrand 2023-08-12 19:23:23 -05:00 committed by Marge Bot
parent 581ee2ccb4
commit 95a3c1325d

View file

@ -569,15 +569,19 @@ nir_rewrite_uses_to_load_reg(nir_builder *b, nir_def *old,
}
static bool
dest_replace_ssa_with_reg(nir_dest *dest, nir_function_impl *impl)
def_replace_with_reg(nir_def *def, nir_function_impl *impl)
{
/* These are handled elsewhere */
assert(def->parent_instr->type != nir_instr_type_ssa_undef &&
def->parent_instr->type != nir_instr_type_load_const);
nir_builder b = nir_builder_create(impl);
nir_def *reg = decl_reg_for_ssa_def(&b, &dest->ssa);
nir_rewrite_uses_to_load_reg(&b, &dest->ssa, reg);
nir_def *reg = decl_reg_for_ssa_def(&b, def);
nir_rewrite_uses_to_load_reg(&b, def, reg);
b.cursor = nir_after_instr(dest->ssa.parent_instr);
nir_store_reg(&b, &dest->ssa, reg);
b.cursor = nir_after_instr(def->parent_instr);
nir_store_reg(&b, def, reg);
return true;
}
@ -1177,10 +1181,10 @@ struct ssa_def_to_reg_state {
};
static bool
dest_replace_ssa_with_reg_state(nir_dest *dest, void *void_state)
def_replace_with_reg_state(nir_def *def, void *void_state)
{
struct ssa_def_to_reg_state *state = void_state;
state->progress |= dest_replace_ssa_with_reg(dest, state->impl);
state->progress |= def_replace_with_reg(def, state->impl);
return true;
}
@ -1262,7 +1266,7 @@ nir_lower_ssa_defs_to_regs_block(nir_block *block)
* don't have a reason to convert it to a register.
*/
} else {
nir_foreach_dest(instr, dest_replace_ssa_with_reg_state, &state);
nir_foreach_def(instr, def_replace_with_reg_state, &state);
}
}