From b024102d7c2959451bfef323432beaa4dca4dd88 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Thu, 2 Dec 2021 10:31:57 -0800 Subject: [PATCH] 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: --- src/compiler/nir/nir_opt_offsets.c | 7 +++++++ src/freedreno/ir3/ir3_nir.c | 1 + 2 files changed, 8 insertions(+) diff --git a/src/compiler/nir/nir_opt_offsets.c b/src/compiler/nir/nir_opt_offsets.c index e2ec1daeded..471fab1747d 100644 --- a/src/compiler/nir/nir_opt_offsets.c +++ b/src/compiler/nir/nir_opt_offsets.c @@ -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); diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index 9db9b367f84..ccf3bdab63d 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -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,