nir/opt_sink: Sink load_constant_agx
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 19 Aug 2023 23:49:09 +0000 (19:49 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 18 Sep 2023 12:38:16 +0000 (08:38 -0400)
By the time this runs, we will have already lowered load_ubo and load_vbo to
load_constant_agx so we need to handle the backend version.

This is very important for reducing register pressure in monolithic VS+GS
shaders on AGX. Since no other backend has _agx intrinsics, there's no need for
an option to gate this.

The additional instruction count is from more frequent wait instructions due to
fewer instructions grouped together. This should be mitigated in the future with
an ACO-style latency-reducing scheduler in the backend, after register pressure
is reduced by opt_sink.

total instructions in shared programs: 1793385 -> 1796101 (0.15%)
instructions in affected programs: 199816 -> 202532 (1.36%)
helped: 3
HURT: 941
Instructions are HURT.

total bytes in shared programs: 11799628 -> 11805004 (0.05%)
bytes in affected programs: 1345656 -> 1351032 (0.40%)
helped: 34
HURT: 919
Bytes are HURT.

total halfregs in shared programs: 533151 -> 525818 (-1.38%)
halfregs in affected programs: 40335 -> 33002 (-18.18%)
helped: 613
HURT: 42
Halfregs are helped.

total threads in shared programs: 18910464 -> 18916608 (0.03%)
threads in affected programs: 6144 -> 12288 (100.00%)
helped: 12
HURT: 0
Threads are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24833>

src/compiler/nir/nir_opt_sink.c

index f6b4cb1..447fa68 100644 (file)
@@ -65,6 +65,8 @@ nir_can_move_instr(nir_instr *instr, nir_move_options options)
          return options & nir_move_load_input;
       case nir_intrinsic_load_uniform:
          return options & nir_move_load_uniform;
+      case nir_intrinsic_load_constant_agx:
+         return true;
       default:
          return false;
       }