From e7c6037d12211c94c24839291d73bbddc19ca184 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Fri, 18 Apr 2025 09:38:38 +0200 Subject: [PATCH] ir3: use opt_shrink_vectors This is useful to remove unused components from IO loads. This is not only helpful for reducing the size of memory loads, but also for reducing register pressure (as we need smaller vector registers). Totals from 55567 (33.76% of 164575) affected shaders: MaxWaves: 665780 -> 666690 (+0.14%); split: +0.15%, -0.01% Instrs: 30850106 -> 30825516 (-0.08%); split: -0.33%, +0.25% CodeSize: 62502952 -> 62336580 (-0.27%); split: -0.42%, +0.15% NOPs: 5468972 -> 5463654 (-0.10%); split: -1.39%, +1.30% MOVs: 1078607 -> 1060627 (-1.67%); split: -3.48%, +1.81% Full: 807907 -> 805134 (-0.34%); split: -0.49%, +0.15% (ss): 755846 -> 747963 (-1.04%); split: -2.51%, +1.46% (sy): 367032 -> 363947 (-0.84%); split: -1.88%, +1.04% (ss)-stall: 2907874 -> 2900183 (-0.26%); split: -1.97%, +1.71% (sy)-stall: 10812082 -> 10599944 (-1.96%); split: -3.43%, +1.47% STPs: 23062 -> 22980 (-0.36%) LDPs: 35076 -> 32286 (-7.95%) Preamble Instrs: 6668422 -> 6612037 (-0.85%); split: -1.35%, +0.51% Early Preamble: 36055 -> 36169 (+0.32%); split: +0.32%, -0.01% Cat0: 6015654 -> 6009409 (-0.10%); split: -1.29%, +1.18% Cat1: 1631110 -> 1610537 (-1.26%); split: -2.54%, +1.28% Cat2: 11783599 -> 11783634 (+0.00%); split: -0.02%, +0.02% Cat3: 8198147 -> 8198526 (+0.00%); split: -0.00%, +0.01% Cat5: 968517 -> 967899 (-0.06%); split: -0.06%, +0.00% Cat6: 349200 -> 351795 (+0.74%); split: -0.01%, +0.75% Cat7: 1009072 -> 1008909 (-0.02%); split: -0.58%, +0.56% Signed-off-by: Job Noorman Part-of: --- src/freedreno/ir3/ir3_nir.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index c548dd507bf..02810cfbdc6 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -363,6 +363,9 @@ ir3_optimize_loop(struct ir3_compiler *compiler, progress |= OPT(s, nir_lower_bit_size, ir3_lower_bit_size, NULL); progress |= OPT(s, nir_opt_constant_folding); + /* Remove unused components from IO loads. */ + progress |= OPT(s, nir_opt_shrink_vectors, true); + const nir_opt_offsets_options offset_options = { /* How large an offset we can encode in the instr's immediate field. */