From 1ee9b8b668ff227b7a7e8992323acacc03da540b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 8 Jan 2024 16:58:11 -0400 Subject: [PATCH] asahi: optimize more when linking libagx Otherwise we get spurious scratch from lower_vars_to_explicit_types on dead vars. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 5 +++++ src/asahi/lib/agx_nir_lower_gs.c | 1 + 2 files changed, 6 insertions(+) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 2def3f0b8e0..207f22f133a 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -2897,6 +2897,11 @@ link_libagx(nir_shader *nir, const nir_shader *libagx) nir_link_shader_functions(nir, libagx); NIR_PASS(_, nir, nir_inline_functions); nir_remove_non_entrypoints(nir); + NIR_PASS(_, nir, nir_opt_deref); + NIR_PASS(_, nir, nir_lower_vars_to_ssa); + NIR_PASS(_, nir, nir_remove_dead_derefs); + NIR_PASS(_, nir, nir_remove_dead_variables, + nir_var_function_temp | nir_var_shader_temp, NULL); NIR_PASS(_, nir, nir_lower_vars_to_explicit_types, nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared | nir_var_mem_global, diff --git a/src/asahi/lib/agx_nir_lower_gs.c b/src/asahi/lib/agx_nir_lower_gs.c index e5edc8a5afe..13456810fd0 100644 --- a/src/asahi/lib/agx_nir_lower_gs.c +++ b/src/asahi/lib/agx_nir_lower_gs.c @@ -1021,6 +1021,7 @@ link_libagx(nir_shader *nir, const nir_shader *libagx) NIR_PASS(_, nir, nir_inline_functions); nir_remove_non_entrypoints(nir); NIR_PASS(_, nir, nir_lower_indirect_derefs, nir_var_function_temp, 64); + NIR_PASS(_, nir, nir_opt_dce); NIR_PASS(_, nir, nir_lower_vars_to_explicit_types, nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared | nir_var_mem_global,