mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-01 03:10:09 +01:00
nir/instr_set: don't ralloc the set
Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36728>
This commit is contained in:
parent
c1ae58d479
commit
68b80e4d25
5 changed files with 22 additions and 17 deletions
|
|
@ -771,16 +771,16 @@ cmp_func(const void *data1, const void *data2)
|
|||
return nir_instrs_equal(data1, data2);
|
||||
}
|
||||
|
||||
struct set *
|
||||
nir_instr_set_create(void *mem_ctx)
|
||||
void
|
||||
nir_instr_set_init(struct set *s, void *mem_ctx)
|
||||
{
|
||||
return _mesa_set_create(mem_ctx, hash_instr, cmp_func);
|
||||
_mesa_set_init(s, mem_ctx, hash_instr, cmp_func);
|
||||
}
|
||||
|
||||
void
|
||||
nir_instr_set_destroy(struct set *instr_set)
|
||||
nir_instr_set_fini(struct set *instr_set)
|
||||
{
|
||||
_mesa_set_destroy(instr_set, NULL);
|
||||
_mesa_set_fini(instr_set, NULL);
|
||||
}
|
||||
|
||||
nir_instr *
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@
|
|||
/*@{*/
|
||||
|
||||
/** Creates an instruction set, using a given ralloc mem_ctx */
|
||||
struct set *nir_instr_set_create(void *mem_ctx);
|
||||
void nir_instr_set_init(struct set *s, void *mem_ctx);
|
||||
|
||||
/** Destroys an instruction set. */
|
||||
void nir_instr_set_destroy(struct set *instr_set);
|
||||
void nir_instr_set_fini(struct set *instr_set);
|
||||
|
||||
/**
|
||||
* Adds an instruction to an instruction set if it doesn't exist. If it does
|
||||
|
|
|
|||
|
|
@ -37,16 +37,17 @@ dominates(const nir_instr *old_instr, const nir_instr *new_instr)
|
|||
static bool
|
||||
nir_opt_cse_impl(nir_function_impl *impl)
|
||||
{
|
||||
struct set *instr_set = nir_instr_set_create(NULL);
|
||||
struct set instr_set;
|
||||
nir_instr_set_init(&instr_set, NULL);
|
||||
|
||||
_mesa_set_resize(instr_set, impl->ssa_alloc);
|
||||
_mesa_set_resize(&instr_set, impl->ssa_alloc);
|
||||
|
||||
nir_metadata_require(impl, nir_metadata_dominance);
|
||||
|
||||
bool progress = false;
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (nir_instr_set_add_or_rewrite(instr_set, instr, dominates)) {
|
||||
if (nir_instr_set_add_or_rewrite(&instr_set, instr, dominates)) {
|
||||
progress = true;
|
||||
nir_instr_remove(instr);
|
||||
}
|
||||
|
|
@ -55,7 +56,7 @@ nir_opt_cse_impl(nir_function_impl *impl)
|
|||
|
||||
nir_progress(progress, impl, nir_metadata_control_flow);
|
||||
|
||||
nir_instr_set_destroy(instr_set);
|
||||
nir_instr_set_fini(&instr_set);
|
||||
return progress;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -831,18 +831,20 @@ opt_gcm_impl(nir_shader *shader, nir_function_impl *impl, bool value_number)
|
|||
* on both sides of the same if/else block, we allow them to be moved.
|
||||
* This cleans up a lot of mess without being -too- aggressive.
|
||||
*/
|
||||
struct set *gvn_set = nir_instr_set_create(NULL);
|
||||
struct set gvn_set;
|
||||
nir_instr_set_init(&gvn_set, NULL);
|
||||
|
||||
foreach_list_typed_safe(nir_instr, instr, node, &state.instrs) {
|
||||
if (instr->pass_flags & GCM_INSTR_PINNED)
|
||||
continue;
|
||||
|
||||
if (nir_instr_set_add_or_rewrite(gvn_set, instr,
|
||||
if (nir_instr_set_add_or_rewrite(&gvn_set, instr,
|
||||
value_number ? NULL : weak_gvn)) {
|
||||
state.progress = true;
|
||||
nir_instr_remove(instr);
|
||||
}
|
||||
}
|
||||
nir_instr_set_destroy(gvn_set);
|
||||
nir_instr_set_fini(&gvn_set);
|
||||
|
||||
foreach_list_typed(nir_instr, instr, node, &state.instrs)
|
||||
gcm_schedule_early_instr(instr, &state);
|
||||
|
|
|
|||
|
|
@ -690,7 +690,9 @@ ir3_nir_opt_prefetch_descriptors(nir_shader *nir, struct ir3_shader_variant *v)
|
|||
const struct ir3_const_state *const_state = ir3_const_state(v);
|
||||
|
||||
nir_function_impl *main = nir_shader_get_entrypoint(nir);
|
||||
struct set *instr_set = nir_instr_set_create(NULL);
|
||||
struct set instr_set;
|
||||
nir_instr_set_init(&instr_set, NULL);
|
||||
|
||||
nir_function_impl *preamble = main->preamble ? main->preamble->impl : NULL;
|
||||
nir_builder b;
|
||||
bool progress = false;
|
||||
|
|
@ -777,7 +779,7 @@ ir3_nir_opt_prefetch_descriptors(nir_shader *nir, struct ir3_shader_variant *v)
|
|||
continue;
|
||||
|
||||
preamble_descs[i] =
|
||||
ir3_rematerialize_def_for_preamble(&b, descs[i], instr_set,
|
||||
ir3_rematerialize_def_for_preamble(&b, descs[i], &instr_set,
|
||||
preamble_defs);
|
||||
}
|
||||
|
||||
|
|
@ -799,7 +801,7 @@ finished:
|
|||
nir_metadata_block_index | nir_metadata_dominance);
|
||||
}
|
||||
|
||||
nir_instr_set_destroy(instr_set);
|
||||
nir_instr_set_fini(&instr_set);
|
||||
free(preamble_defs);
|
||||
return progress;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue