From e4f0de89a5676093629da6e2da1b779820a16259 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sat, 22 Feb 2025 13:07:49 +0100 Subject: [PATCH] nir/opt_phi_precision: use nir_shader_phi_pass Reviewed-by: Konstantin Seurer Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_opt_phi_precision.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/compiler/nir/nir_opt_phi_precision.c b/src/compiler/nir/nir_opt_phi_precision.c index 3b7f86bc4d5..f37adda2c8a 100644 --- a/src/compiler/nir/nir_opt_phi_precision.c +++ b/src/compiler/nir/nir_opt_phi_precision.c @@ -427,7 +427,7 @@ try_move_widening_src(nir_builder *b, nir_phi_instr *phi) } static bool -lower_phi(nir_builder *b, nir_phi_instr *phi) +opt_phi_precision(nir_builder *b, nir_phi_instr *phi, void *unused) { bool progress = try_move_narrowing_dst(b, phi); if (!progress) @@ -438,8 +438,6 @@ lower_phi(nir_builder *b, nir_phi_instr *phi) bool nir_opt_phi_precision(nir_shader *shader) { - bool progress = false; - /* If 8b or 16b bit_sizes are not used, no point to run this pass: */ unsigned bit_sizes_used = shader->info.bit_sizes_float | shader->info.bit_sizes_int; @@ -450,21 +448,6 @@ nir_opt_phi_precision(nir_shader *shader) if (bit_sizes_used && !(bit_sizes_used & (8 | 16))) return false; - nir_foreach_function_impl(impl, shader) { - nir_builder b = nir_builder_create(impl); - - nir_foreach_block(block, impl) { - nir_foreach_phi_safe(phi, block) - progress |= lower_phi(&b, phi); - } - - if (progress) { - nir_metadata_preserve(impl, - nir_metadata_control_flow); - } else { - nir_metadata_preserve(impl, nir_metadata_all); - } - } - - return progress; + return nir_shader_phi_pass(shader, opt_phi_precision, + nir_metadata_control_flow, NULL); }