From a3696f29c1b9bde543614ac1745c49df78f9ef85 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 22 Oct 2024 16:15:07 -0400 Subject: [PATCH] agx: run algebraic later MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to deal with ldst vectorize leftover ironically worse due to nir_opt_preamble lottery, but confirmed it fixes ldst vectorize silliness in preambles, making preambles a *lot* shorter. total instructions in shared programs: 2759806 -> 2759882 (<.01%) instructions in affected programs: 26821 -> 26897 (0.28%) helped: 0 HURT: 10 HURT stats (abs) min: 1 max: 15 x̄: 7.60 x̃: 6 HURT stats (rel) min: 0.07% max: 1.33% x̄: 0.47% x̃: 0.19% 95% mean confidence interval for instructions value: 3.65 11.55 95% mean confidence interval for instructions %-change: 0.09% 0.85% Instructions are HURT. total alu in shared programs: 2174292 -> 2174340 (<.01%) alu in affected programs: 25727 -> 25775 (0.19%) helped: 1 HURT: 10 helped stats (abs) min: 2 max: 2 x̄: 2.00 x̃: 2 helped stats (rel) min: 0.05% max: 0.05% x̄: 0.05% x̃: 0.05% HURT stats (abs) min: 1 max: 11 x̄: 5.00 x̃: 4 HURT stats (rel) min: 0.09% max: 0.52% x̄: 0.27% x̃: 0.23% 95% mean confidence interval for alu value: 1.92 6.81 95% mean confidence interval for alu %-change: 0.12% 0.37% Alu are HURT. total fscib in shared programs: 2170011 -> 2170059 (<.01%) fscib in affected programs: 25727 -> 25775 (0.19%) helped: 1 HURT: 10 helped stats (abs) min: 2 max: 2 x̄: 2.00 x̃: 2 helped stats (rel) min: 0.05% max: 0.05% x̄: 0.05% x̃: 0.05% HURT stats (abs) min: 1 max: 11 x̄: 5.00 x̃: 4 HURT stats (rel) min: 0.09% max: 0.52% x̄: 0.27% x̃: 0.23% 95% mean confidence interval for fscib value: 1.92 6.81 95% mean confidence interval for fscib %-change: 0.12% 0.37% Fscib are HURT. total bytes in shared programs: 18414728 -> 18415244 (<.01%) bytes in affected programs: 234114 -> 234630 (0.22%) helped: 1 HURT: 11 helped stats (abs) min: 8 max: 8 x̄: 8.00 x̃: 8 helped stats (rel) min: 0.02% max: 0.02% x̄: 0.02% x̃: 0.02% HURT stats (abs) min: 4 max: 90 x̄: 47.64 x̃: 34 HURT stats (rel) min: 0.03% max: 1.18% x̄: 0.39% x̃: 0.18% 95% mean confidence interval for bytes value: 20.47 65.53 95% mean confidence interval for bytes %-change: 0.08% 0.63% Bytes are HURT. total regs in shared programs: 864549 -> 864533 (<.01%) regs in affected programs: 117 -> 101 (-13.68%) helped: 3 HURT: 0 helped stats (abs) min: 4 max: 6 x̄: 5.33 x̃: 6 helped stats (rel) min: 10.26% max: 15.38% x̄: 13.68% x̃: 15.38% Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 411f411482d..afe1b38e0e4 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -3004,13 +3004,19 @@ agx_optimize_nir(nir_shader *nir, bool soft_fault, unsigned *preamble_size) NIR_PASS(progress, nir, nir_opt_uniform_atomics, true); NIR_PASS(progress, nir, nir_opt_uniform_subgroup, &subgroups_options); - - /* The above create operations that need lowering/optimizing */ if (progress) { NIR_PASS(_, nir, agx_nir_lower_subgroups); - NIR_PASS(_, nir, nir_opt_algebraic); } + /* The above create operations that need lowering/optimizing */ + do { + progress = false; + + NIR_PASS(progress, nir, nir_opt_algebraic); + NIR_PASS(progress, nir, nir_opt_constant_folding); + NIR_PASS(progress, nir, nir_opt_dce); + } while (progress); + progress = false; NIR_PASS(progress, nir, agx_nir_lower_address);