mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 03:38:06 +02:00
nir/instr_set: Don't remove matching instruction
We currently assume that the instruction is already inserted and we are optimizing it away, but in the use case I have where we are hoisting instructions into a preamble and deduplicating as we go along, that isn't the case. Move this responsibility onto the caller, which also makes it a bit clearer what's going on and turns this into something more similar to an actual set. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29873>
This commit is contained in:
parent
cda7d9c971
commit
ccf88d940b
4 changed files with 5 additions and 3 deletions
|
|
@ -778,8 +778,6 @@ nir_instr_set_add_or_rewrite(struct set *instr_set, nir_instr *instr,
|
|||
|
||||
nir_def_rewrite_uses(def, new_def);
|
||||
|
||||
nir_instr_remove(instr);
|
||||
|
||||
return match;
|
||||
} else {
|
||||
/* otherwise, replace hashed instruction */
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ nir_opt_cse_impl(nir_function_impl *impl)
|
|||
nir_foreach_instr_safe(instr, block) {
|
||||
if (nir_instr_set_add_or_rewrite(instr_set, instr, dominates)) {
|
||||
progress = true;
|
||||
nir_instr_remove(instr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -838,8 +838,10 @@ opt_gcm_impl(nir_shader *shader, nir_function_impl *impl, bool value_number)
|
|||
continue;
|
||||
|
||||
if (nir_instr_set_add_or_rewrite(gvn_set, instr,
|
||||
value_number ? NULL : weak_gvn))
|
||||
value_number ? NULL : weak_gvn)) {
|
||||
state.progress = true;
|
||||
nir_instr_remove(instr);
|
||||
}
|
||||
}
|
||||
nir_instr_set_destroy(gvn_set);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ nir_opt_reuse_constants(nir_shader *shader)
|
|||
|
||||
if (nir_instr_set_add_or_rewrite(consts, instr, nir_instrs_equal)) {
|
||||
func_progress = true;
|
||||
nir_instr_remove(instr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue