From 356c279daa62a6f6e4b56432dfee1d6893c36748 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Sun, 12 Apr 2026 17:44:06 +0200 Subject: [PATCH] nak: run nir_opt_constant_folding after nak_nir_lower_load_store It seems beneficial to run constant_folding after we lower our load/stores as it allows nir_opt_offsets to move even more constants into the base index. This will prevent perf regressions when moving more lowering into nak_nir_lower_load_store. Totals from 78165 (6.44% of 1212873) affected shaders: CodeSize: 1834431840 -> 1780937808 (-2.92%); split: -2.92%, +0.00% Number of GPRs: 5233739 -> 5234571 (+0.02%); split: -0.01%, +0.03% Static cycle count: 1855933069 -> 1851091739 (-0.26%); split: -0.26%, +0.00% Spills to memory: 12453 -> 12451 (-0.02%) Fills from memory: 12453 -> 12451 (-0.02%) Spills to reg: 69790 -> 69754 (-0.05%); split: -0.08%, +0.03% Fills from reg: 57092 -> 57072 (-0.04%); split: -0.07%, +0.03% Max warps/SM: 2572632 -> 2572196 (-0.02%); split: +0.01%, -0.02% --- src/nouveau/compiler/nak_nir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nouveau/compiler/nak_nir.c b/src/nouveau/compiler/nak_nir.c index 27a3384f5cd..297c95e90e5 100644 --- a/src/nouveau/compiler/nak_nir.c +++ b/src/nouveau/compiler/nak_nir.c @@ -1307,7 +1307,8 @@ nak_postprocess_nir(nir_shader *nir, UNREACHABLE("Unsupported shader stage"); } - OPT(nir, nak_nir_lower_load_store, nak); + if (OPT(nir, nak_nir_lower_load_store, nak)) + OPT(nir, nir_opt_constant_folding); struct nir_opt_offsets_options nak_offset_options = { .max_offset_cb = nak_nir_max_imm_offset,