nak: sink ubo and ssbo loads before load/store lowering

Our own lowering of bounded loads adds ALU instruction that make it
unviable to run this later for ssbos and ubos, which also include
load_global_bounded (ssbo) and load_global_constant_* (ubo).

There are some regressions, but in many cases loads get moved down into
control flow which makes them less likely to be executed, so we can take
the hit as it's overall an improvement.

Other regressions come from RA having a more difficult time to allocate
registers well enough around control flow.

Totals from 76135 (6.28% of 1212873) affected shaders:
CodeSize: 2042701584 -> 2040842272 (-0.09%); split: -0.30%, +0.21%
Number of GPRs: 5710526 -> 5642243 (-1.20%); split: -1.49%, +0.29%
SLM Size: 364520 -> 362628 (-0.52%); split: -0.54%, +0.02%
Static cycle count: 2318074214 -> 2368034561 (+2.16%); split: -0.17%, +2.32%
Spills to memory: 28423 -> 27656 (-2.70%); split: -3.92%, +1.22%
Fills from memory: 28423 -> 27656 (-2.70%); split: -3.92%, +1.22%
Spills to reg: 108907 -> 112461 (+3.26%); split: -3.02%, +6.28%
Fills from reg: 88071 -> 89601 (+1.74%); split: -2.90%, +4.64%
Max warps/SM: 2297172 -> 2317116 (+0.87%); split: +1.17%, -0.31%
This commit is contained in:
Karol Herbst 2026-04-12 02:25:22 +02:00 committed by Karol Herbst
parent 93758c43c3
commit 81095eb0c0

View file

@ -1330,6 +1330,8 @@ nak_postprocess_nir(nir_shader *nir,
UNREACHABLE("Unsupported shader stage");
}
/* sink memory loads once before we add our own bound checking */
OPT(nir, nir_opt_sink, nir_move_load_ssbo | nir_move_load_ubo);
if (OPT(nir, nak_nir_lower_load_store, nak))
OPT(nir, nir_opt_constant_folding);