nir/opt_dce: fixup for new foreach_block()
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:

committed by
Jason Ekstrand

parent
3afb3be674
commit
ddc6639f85
@@ -113,10 +113,8 @@ init_instr(nir_instr *instr, struct exec_list *worklist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
init_block_cb(nir_block *block, void *_state)
|
init_block(nir_block *block, struct exec_list *worklist)
|
||||||
{
|
{
|
||||||
struct exec_list *worklist = (struct exec_list *) _state;
|
|
||||||
|
|
||||||
nir_foreach_instr(block, instr)
|
nir_foreach_instr(block, instr)
|
||||||
init_instr(instr, worklist);
|
init_instr(instr, worklist);
|
||||||
|
|
||||||
@@ -130,28 +128,15 @@ init_block_cb(nir_block *block, void *_state)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
delete_block_cb(nir_block *block, void *_state)
|
|
||||||
{
|
|
||||||
bool *progress = (bool *) _state;
|
|
||||||
|
|
||||||
nir_foreach_instr_safe(block, instr) {
|
|
||||||
if (!instr->pass_flags) {
|
|
||||||
nir_instr_remove(instr);
|
|
||||||
*progress = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
nir_opt_dce_impl(nir_function_impl *impl)
|
nir_opt_dce_impl(nir_function_impl *impl)
|
||||||
{
|
{
|
||||||
struct exec_list *worklist = ralloc(NULL, struct exec_list);
|
struct exec_list *worklist = ralloc(NULL, struct exec_list);
|
||||||
exec_list_make_empty(worklist);
|
exec_list_make_empty(worklist);
|
||||||
|
|
||||||
nir_foreach_block_call(impl, init_block_cb, worklist);
|
nir_foreach_block(block, impl) {
|
||||||
|
init_block(block, worklist);
|
||||||
|
}
|
||||||
|
|
||||||
while (!exec_list_is_empty(worklist)) {
|
while (!exec_list_is_empty(worklist)) {
|
||||||
nir_instr *instr = worklist_pop(worklist);
|
nir_instr *instr = worklist_pop(worklist);
|
||||||
@@ -161,7 +146,15 @@ nir_opt_dce_impl(nir_function_impl *impl)
|
|||||||
ralloc_free(worklist);
|
ralloc_free(worklist);
|
||||||
|
|
||||||
bool progress = false;
|
bool progress = false;
|
||||||
nir_foreach_block_call(impl, delete_block_cb, &progress);
|
|
||||||
|
nir_foreach_block(block, impl) {
|
||||||
|
nir_foreach_instr_safe(block, instr) {
|
||||||
|
if (!instr->pass_flags) {
|
||||||
|
nir_instr_remove(instr);
|
||||||
|
progress = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (progress)
|
if (progress)
|
||||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||||
|
Reference in New Issue
Block a user