freedreno/ir3: Use nir_opt_offset for removing constant adds for shared vars.
authorEmma Anholt <emma@anholt.net>
Thu, 2 Dec 2021 18:31:57 +0000 (10:31 -0800)
committerMarge Bot <emma+marge@anholt.net>
Sun, 16 Jan 2022 19:11:29 +0000 (19:11 +0000)
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>

src/compiler/nir/nir_opt_offsets.c
src/freedreno/ir3/ir3_nir.c

index e2ec1da..471fab1 100644 (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);
index 9db9b36..ccf3bda 100644 (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,