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>
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);
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;
}
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);
#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 */