From c5c90e6ea4957c9d6bc501bbbe7ae33087d98c27 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 1 Jun 2022 14:43:18 -0500 Subject: [PATCH] lima: Lower undefs to zero and run DCE after from_ssa MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Undefs can happen even in real GLSL shaders so it's best to handle them. Lowering to zero is a perfectly valid implementation. Also, run DCE because some of the undefs may be dead after from_ssa and there's no point in processing those in the back-end. Reviewed-by: Daniel Schürmann Part-of: --- src/gallium/drivers/lima/lima_program.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c index 8ce554d194a..1b50ea7a697 100644 --- a/src/gallium/drivers/lima/lima_program.c +++ b/src/gallium/drivers/lima/lima_program.c @@ -139,6 +139,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s) NIR_PASS(progress, s, lima_nir_lower_ftrunc); NIR_PASS(progress, s, nir_opt_constant_folding); NIR_PASS(progress, s, nir_opt_undef); + NIR_PASS(progress, s, nir_lower_undef_to_zero); NIR_PASS(progress, s, nir_opt_loop_unroll); NIR_PASS(progress, s, nir_lower_undef_to_zero); } while (progress); @@ -153,6 +154,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s) NIR_PASS_V(s, lima_nir_split_loads); NIR_PASS_V(s, nir_lower_locals_to_regs); NIR_PASS_V(s, nir_convert_from_ssa, true); + NIR_PASS_V(s, nir_opt_dce); NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL); nir_sweep(s); }