agx: reassociate ALU

GL:

   total instrs in shared programs: 2881862 -> 2801415 (-2.79%)
   instrs in affected programs: 2264277 -> 2183830 (-3.55%)

   total alu in shared programs: 2362306 -> 2281986 (-3.40%)
   alu in affected programs: 1882190 -> 1801870 (-4.27%)

   total fscib in shared programs: 2359848 -> 2279314 (-3.41%)
   fscib in affected programs: 1891013 -> 1810479 (-4.26%)

   total ic in shared programs: 661722 -> 661702 (<.01%)
   ic in affected programs: 1304 -> 1284 (-1.53%)

   total gprs in shared programs: 899341 -> 900319 (0.11%)
   gprs in affected programs: 48696 -> 49674 (2.01%)

   total uniforms in shared programs: 2069880 -> 2064570 (-0.26%)
   uniforms in affected programs: 426411 -> 421101 (-1.25%)

   total threads in shared programs: 27802432 -> 27802624 (<.01%)
   threads in affected programs: 5568 -> 5760 (3.45%)

   total preamble in shared programs: 1202295 -> 1222360 (1.67%)
   preamble in affected programs: 452890 -> 472955 (4.43%)

VK:

   Totals:
   MaxWaves: 53077184 -> 53075712 (-0.00%); split: +0.05%, -0.05%
   Instrs: 23845634 -> 23561020 (-1.19%); split: -1.22%, +0.02%
   CodeSize: 170339242 -> 168601666 (-1.02%); split: -1.04%, +0.02%
   Spills: 65594 -> 65784 (+0.29%); split: -1.43%, +1.72%
   Fills: 43190 -> 43178 (-0.03%); split: -2.21%, +2.18%
   Scratch: 404208 -> 403474 (-0.18%); split: -0.27%, +0.08%
   ALU: 18566800 -> 18288141 (-1.50%); split: -1.52%, +0.02%
   FSCIB: 18511881 -> 18230860 (-1.52%); split: -1.54%, +0.02%
   IC: 5260462 -> 5259748 (-0.01%); split: -0.02%, +0.00%
   GPRs: 3831837 -> 3838887 (+0.18%); split: -0.25%, +0.43%
   Uniforms: 10453510 -> 10443173 (-0.10%); split: -0.29%, +0.19%
   Preamble instrs: 10409287 -> 10496713 (+0.84%); split: -0.10%, +0.94%

   Totals from 32343 (59.87% of 54019) affected shaders:
   MaxWaves: 31027072 -> 31025600 (-0.00%); split: +0.08%, -0.08%
   Instrs: 19806186 -> 19521572 (-1.44%); split: -1.46%, +0.03%
   CodeSize: 141121024 -> 139383448 (-1.23%); split: -1.25%, +0.02%
   Spills: 65252 -> 65442 (+0.29%); split: -1.44%, +1.73%
   Fills: 42745 -> 42733 (-0.03%); split: -2.23%, +2.20%
   Scratch: 403096 -> 402362 (-0.18%); split: -0.27%, +0.08%
   ALU: 15544339 -> 15265680 (-1.79%); split: -1.82%, +0.03%
   FSCIB: 15491754 -> 15210733 (-1.81%); split: -1.84%, +0.03%
   IC: 4817376 -> 4816662 (-0.01%); split: -0.02%, +0.01%
   GPRs: 2735551 -> 2742601 (+0.26%); split: -0.35%, +0.61%
   Uniforms: 7717506 -> 7707169 (-0.13%); split: -0.39%, +0.25%
   Preamble instrs: 7713698 -> 7801124 (+1.13%); split: -0.14%, +1.27%

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36147>
This commit is contained in:
Alyssa Rosenzweig
2025-07-19 11:20:23 -04:00
committed by Marge Bot
parent 7a786a9c7a
commit 803e61837e

View File

@@ -3154,7 +3154,16 @@ agx_optimize_nir(nir_shader *nir, bool soft_fault, uint16_t *preamble_size,
} while (progress);
}
/* Reassociate before forming preambles because it makes preambles more
* effective. Clean up after.
*/
for (unsigned i = 0; i < 4; ++i) {
nir_reassociate_options opts = nir_reassociate_scalar_math;
if (i < 2)
opts |= nir_reassociate_cse_heuristic;
NIR_PASS(_, nir, nir_opt_reassociate, opts);
do {
progress = false;