pan/bi: Use a progress loop for constant folding

Needed to fold the dependent patterns produced by texture instructions
during NIR->Valhall.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15204>
This commit is contained in:
Alyssa Rosenzweig 2021-12-22 13:22:21 -05:00 committed by Marge Bot
parent e5582710f3
commit 3154df232b
3 changed files with 11 additions and 4 deletions

View file

@ -81,9 +81,11 @@ bi_fold_constant(bi_instr *I, bool *unsupported)
return 0;
}
void
bool
bi_opt_constant_fold(bi_context *ctx)
{
bool progress = false;
bi_foreach_instr_global_safe(ctx, ins) {
bool unsupported = false;
uint32_t replace = bi_fold_constant(ins, &unsupported);
@ -93,5 +95,8 @@ bi_opt_constant_fold(bi_context *ctx)
bi_builder b = bi_init_builder(ctx, bi_after_instr(ins));
bi_mov_i32_to(&b, ins->dest[0], bi_imm_u32(replace));
bi_remove_instruction(ins);
progress = true;
}
return progress;
}

View file

@ -4009,8 +4009,10 @@ bi_compile_variant_nir(nir_shader *nir,
if (likely(optimize)) {
bi_opt_copy_prop(ctx);
bi_opt_constant_fold(ctx);
bi_opt_copy_prop(ctx);
while (bi_opt_constant_fold(ctx))
bi_opt_copy_prop(ctx);
bi_opt_mod_prop_forward(ctx);
bi_opt_mod_prop_backward(ctx);

View file

@ -1013,7 +1013,7 @@ static inline void bi_validate(UNUSED bi_context *ctx, UNUSED const char *after_
#endif
uint32_t bi_fold_constant(bi_instr *I, bool *unsupported);
void bi_opt_constant_fold(bi_context *ctx);
bool bi_opt_constant_fold(bi_context *ctx);
/* Liveness */