r300: add late vectorization after nir_move_vec_src_uses_to_dest

Turns out that besides the benefits from nir_move_vec_src_uses_to_dest
itself, it also creates new opportunities for vectorization. Enable it
for vertex shaders, there is a clear instruction win and the only
downside is some increased register presure. However this is mostly
concerning few Unigine Tropics and Sanctiary shaders where we go
11->14 or 10->13 used registers. According to the docs, the increased
register usage would only lower vertex processing concurency if we go
over 15 (R300) or 25 (R500) registers, so we should be safe here.

Fragment shaders are a mixed bag so leave them be for now.

Shader-db RV530
total instructions in shared programs: 129303 -> 128762 (-0.42%)
instructions in affected programs: 13887 -> 13346 (-3.90%)
helped: 99
HURT: 0
total temps in shared programs: 17355 -> 17543 (1.08%)
temps in affected programs: 730 -> 918 (25.75%)
helped: 4
HURT: 66
total cycles in shared programs: 197190 -> 196984 (-0.10%)
cycles in affected programs: 9998 -> 9792 (-2.06%)
helped: 65
HURT: 0

Shader-db RV370:
total instructions in shared programs: 84807 -> 84225 (-0.69%)
instructions in affected programs: 10203 -> 9621 (-5.70%)
helped: 92
HURT: 0
total temps in shared programs: 13036 -> 13231 (1.50%)
temps in affected programs: 787 -> 982 (24.78%)
helped: 4
HURT: 73
total cycles in shared programs: 133178 -> 132946 (-0.17%)
cycles in affected programs: 5911 -> 5679 (-3.92%)
helped: 58

HURT: 0
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25417>
This commit is contained in:
Pavel Ondračka
2023-09-26 17:33:20 +02:00
committed by Marge Bot
parent ad7efdea6e
commit f1c9e90146

View File

@@ -2452,6 +2452,11 @@ const void *nir_to_rc_options(struct nir_shader *s,
NIR_PASS_V(s, nir_opt_move, move_all);
NIR_PASS_V(s, nir_move_vec_src_uses_to_dest, true);
/* Late vectorizing after nir_move_vec_src_uses_to_dest helps instructions but
* increases register usage. Testing shows this is beneficial only in VS.
*/
if (s->info.stage == MESA_SHADER_VERTEX)
NIR_PASS_V(s, nir_opt_vectorize, ntr_should_vectorize_instr, NULL);
NIR_PASS_V(s, nir_convert_from_ssa, true);
NIR_PASS_V(s, nir_lower_vec_to_regs, NULL, NULL);