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

committed by
Jason Ekstrand

parent
26b4c9ee15
commit
eecf96f530
@@ -173,22 +173,21 @@ constant_fold_tex_instr(nir_tex_instr *instr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
constant_fold_block(nir_block *block, void *void_state)
|
constant_fold_block(nir_block *block, void *mem_ctx)
|
||||||
{
|
{
|
||||||
struct constant_fold_state *state = void_state;
|
bool progress = false;
|
||||||
|
|
||||||
nir_foreach_instr_safe(block, instr) {
|
nir_foreach_instr_safe(block, instr) {
|
||||||
switch (instr->type) {
|
switch (instr->type) {
|
||||||
case nir_instr_type_alu:
|
case nir_instr_type_alu:
|
||||||
state->progress |= constant_fold_alu_instr(nir_instr_as_alu(instr),
|
progress |= constant_fold_alu_instr(nir_instr_as_alu(instr), mem_ctx);
|
||||||
state->mem_ctx);
|
|
||||||
break;
|
break;
|
||||||
case nir_instr_type_intrinsic:
|
case nir_instr_type_intrinsic:
|
||||||
state->progress |=
|
progress |=
|
||||||
constant_fold_intrinsic_instr(nir_instr_as_intrinsic(instr));
|
constant_fold_intrinsic_instr(nir_instr_as_intrinsic(instr));
|
||||||
break;
|
break;
|
||||||
case nir_instr_type_tex:
|
case nir_instr_type_tex:
|
||||||
state->progress |= constant_fold_tex_instr(nir_instr_as_tex(instr));
|
progress |= constant_fold_tex_instr(nir_instr_as_tex(instr));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Don't know how to constant fold */
|
/* Don't know how to constant fold */
|
||||||
@@ -196,25 +195,24 @@ constant_fold_block(nir_block *block, void *void_state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
nir_opt_constant_folding_impl(nir_function_impl *impl)
|
nir_opt_constant_folding_impl(nir_function_impl *impl)
|
||||||
{
|
{
|
||||||
struct constant_fold_state state;
|
void *mem_ctx = ralloc_parent(impl);
|
||||||
|
bool progress = false;
|
||||||
|
|
||||||
state.mem_ctx = ralloc_parent(impl);
|
nir_foreach_block(block, impl) {
|
||||||
state.impl = impl;
|
progress |= constant_fold_block(block, mem_ctx);
|
||||||
state.progress = false;
|
}
|
||||||
|
|
||||||
nir_foreach_block_call(impl, constant_fold_block, &state);
|
if (progress)
|
||||||
|
|
||||||
if (state.progress)
|
|
||||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||||
nir_metadata_dominance);
|
nir_metadata_dominance);
|
||||||
|
|
||||||
return state.progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Reference in New Issue
Block a user