From 472a20c5fc0feda0f074b4ff95fd7c7a6305c8cd Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 23 Sep 2020 13:14:26 -0500 Subject: [PATCH] radeonsi: Only call nir_lower_var_copies at the end of the opt loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 283ad85944b5d, radeonsi started using nir_find_var_copies. However, it was also calling nir_lower_var_copies in the optimization loop and the two can end up fighting. The simple solution is to wait to lower copies until the end of the optimization loop. Fixes: 283ad85944b5d Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3550 Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_shader_nir.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 70b2d6991e5..99be45ce5b0 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -496,23 +496,11 @@ static void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool bool lower_phis_to_scalar = false; if (first) { - bool opt_find_array_copies = false; - NIR_PASS(progress, nir, nir_split_array_vars, nir_var_function_temp); NIR_PASS(lower_alu_to_scalar, nir, nir_shrink_vec_array_vars, nir_var_function_temp); - NIR_PASS(opt_find_array_copies, nir, nir_opt_find_array_copies); - NIR_PASS(progress, nir, nir_opt_copy_prop_vars); - - /* Call nir_lower_var_copies() to remove any copies introduced - * by nir_opt_find_array_copies(). - */ - if (opt_find_array_copies) - NIR_PASS(progress, nir, nir_lower_var_copies); - progress |= opt_find_array_copies; - } else { - NIR_PASS(progress, nir, nir_opt_copy_prop_vars); + NIR_PASS(progress, nir, nir_opt_find_array_copies); } - + NIR_PASS(progress, nir, nir_opt_copy_prop_vars); NIR_PASS(progress, nir, nir_opt_dead_write_vars); NIR_PASS(lower_alu_to_scalar, nir, nir_opt_trivial_continues); @@ -564,6 +552,8 @@ static void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool if (sscreen->info.has_packed_math_16bit) NIR_PASS(progress, nir, nir_opt_vectorize, NULL, NULL); } while (progress); + + NIR_PASS_V(nir, nir_lower_var_copies); } static int type_size_vec4(const struct glsl_type *type, bool bindless)