freedreno/ir3: Use nir_opt_offset for removing constant adds for shared vars.

Saves some work in carchase and manhattan31:

instructions in affected programs: 2842 -> 2818 (-0.84%)
nops in affected programs: 1131 -> 1105 (-2.30%)
non-nops in affected programs: 1236 -> 1238 (0.16%)
mov in affected programs: 57 -> 61 (7.02%)
dwords in affected programs: 2144 -> 2150 (0.28%)
cat0 in affected programs: 1195 -> 1169 (-2.18%)
cat1 in affected programs: 151 -> 155 (2.65%)
cat2 in affected programs: 142 -> 140 (-1.41%)
sstall in affected programs: 190 -> 178 (-6.32%)
(ss) in affected programs: 63 -> 63 (0.00%)
systall in affected programs: 532 -> 511 (-3.95%)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14023>
This commit is contained in:
Emma Anholt 2021-12-02 10:31:57 -08:00 committed by Marge Bot
parent 9645fa9107
commit b024102d7c
2 changed files with 8 additions and 0 deletions

View file

@ -128,9 +128,16 @@ process_instr(nir_builder *b, nir_instr *instr, void *s)
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
switch (intrin->intrinsic) {
/* Note that while it's tempting to include nir_intrinsic_load_uniform
* here, freedreno doesn't want that because it can have to move the base
* back to a register plus a small constant offset, and it's not clever
* enough to minimize the code that that emits.
*/
case nir_intrinsic_load_shared:
case nir_intrinsic_load_shared_ir3:
return try_fold_load_store(b, intrin, state, 0);
case nir_intrinsic_store_shared:
case nir_intrinsic_store_shared_ir3:
return try_fold_load_store(b, intrin, state, 1);
case nir_intrinsic_load_buffer_amd:
return try_fold_load_store(b, intrin, state, 1);

View file

@ -117,6 +117,7 @@ ir3_optimize_loop(struct ir3_compiler *compiler, nir_shader *s)
progress |= OPT(s, nir_lower_alu);
progress |= OPT(s, nir_lower_pack);
progress |= OPT(s, nir_opt_constant_folding);
progress |= OPT(s, nir_opt_offsets);
nir_load_store_vectorize_options vectorize_opts = {
.modes = nir_var_mem_ubo,