mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 23:20:08 +01:00
nir: use nir_shader_instructions_pass in nir_lower_alu
Changes: - nir_metadata_preserve(..., nir_metadata_all) is called when pass doesn't make progress - only metadata of the current function is invalidated (invalidation on one function was leaking to successive functions because "progress" was not reset) Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12282>
This commit is contained in:
parent
cb201e92ac
commit
5beeb3c1db
1 changed files with 10 additions and 26 deletions
|
|
@ -40,8 +40,13 @@
|
|||
#define LOWER_MUL_HIGH (1 << 0)
|
||||
|
||||
static bool
|
||||
lower_alu_instr(nir_alu_instr *instr, nir_builder *b)
|
||||
lower_alu_instr(nir_builder *b, nir_instr *instr_, UNUSED void *cb_data)
|
||||
{
|
||||
if (instr_->type != nir_instr_type_alu)
|
||||
return false;
|
||||
|
||||
nir_alu_instr *instr = nir_instr_as_alu(instr_);
|
||||
|
||||
nir_ssa_def *lowered = NULL;
|
||||
|
||||
assert(instr->dest.dest.is_ssa);
|
||||
|
|
@ -223,33 +228,12 @@ lower_alu_instr(nir_alu_instr *instr, nir_builder *b)
|
|||
bool
|
||||
nir_lower_alu(nir_shader *shader)
|
||||
{
|
||||
bool progress = false;
|
||||
|
||||
if (!shader->options->lower_bitfield_reverse &&
|
||||
!shader->options->lower_mul_high)
|
||||
return false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder builder;
|
||||
nir_builder_init(&builder, function->impl);
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type == nir_instr_type_alu) {
|
||||
progress = lower_alu_instr(nir_instr_as_alu(instr),
|
||||
&builder) || progress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return progress;
|
||||
return nir_shader_instructions_pass(shader, lower_alu_instr,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue