From 7a786a9c7ae38d1147a3cc60e2834ec23b66e879 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 16 Jul 2025 15:04:39 -0400 Subject: [PATCH] agx: run more opt passes preparing for reassoc GL mostly noise, Vulkan: Totals from 32853 (60.82% of 54019) affected shaders: MaxWaves: 31747776 -> 31758272 (+0.03%); split: +0.04%, -0.01% Instrs: 18017616 -> 18016663 (-0.01%); split: -0.11%, +0.11% CodeSize: 128159164 -> 128249442 (+0.07%); split: -0.13%, +0.20% Spills: 63634 -> 62658 (-1.53%); split: -1.83%, +0.30% Fills: 42547 -> 41669 (-2.06%); split: -2.51%, +0.44% Scratch: 341914 -> 341748 (-0.05%); split: -0.09%, +0.04% ALU: 13999432 -> 13998308 (-0.01%); split: -0.13%, +0.12% FSCIB: 13979325 -> 13978584 (-0.01%); split: -0.13%, +0.12% IC: 3953418 -> 3957996 (+0.12%); split: -0.03%, +0.14% GPRs: 2621294 -> 2619432 (-0.07%); split: -0.13%, +0.06% Uniforms: 7118591 -> 7040633 (-1.10%); split: -1.91%, +0.82% Preamble instrs: 6800746 -> 6571058 (-3.38%); split: -3.76%, +0.39% Signed-off-by: Alyssa Rosenzweig Acked-by: Adam Jackson Reviewed-by: Mel Henning Part-of: --- src/asahi/compiler/agx_compile.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index f838b6b66ec..f83840819a1 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -3154,8 +3154,21 @@ agx_optimize_nir(nir_shader *nir, bool soft_fault, uint16_t *preamble_size, } while (progress); } + for (unsigned i = 0; i < 4; ++i) { + do { + progress = false; + + NIR_PASS(progress, nir, nir_opt_algebraic); + NIR_PASS(progress, nir, nir_opt_constant_folding); + NIR_PASS(progress, nir, nir_copy_prop); + NIR_PASS(progress, nir, nir_opt_cse); + NIR_PASS(progress, nir, nir_opt_dce); + } while (progress); + } + /* Lower fmin/fmax before optimizing preambles so we can see across uniform - * expressions. + * expressions. Do it after nir_opt_reassociate because nir_opt_reassociate + * should work on unlowered fmin/fmax. */ NIR_PASS(_, nir, agx_nir_lower_fminmax);