nir/sink,nir/move: move/sink nir_op_mov
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 14 Oct 2019 16:15:04 +0000 (17:15 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 14 Jan 2020 13:56:45 +0000 (13:56 +0000)
Can uncover opportunities to move other instructions. This can increase
register usage, but that doesn't seem to actually happen.

This optimizes a pattern of a load_per_vertex_input followed by several
moves and then a store_output in a different block.

v2: add nir_move_copies to make it optional

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net> (v1)
Acked-by: Rob Clark <robdclark@chromium.org>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2420>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2420>

src/compiler/nir/nir.h
src/compiler/nir/nir_opt_sink.c

index 4b6294d7bea20f784ab4d3a20c87287010f86dfb..a8e4184f1d5a1c894b45062826f1d872f193a421 100644 (file)
@@ -4217,6 +4217,7 @@ typedef enum {
     nir_move_load_ubo    = (1 << 1),
     nir_move_load_input  = (1 << 2),
     nir_move_comparisons = (1 << 3),
+    nir_move_copies      = (1 << 4),
 } nir_move_options;
 
 bool nir_can_move_instr(nir_instr *instr, nir_move_options options);
index e68ad9cd607a2ddaef06978a8ea9d3edd83b4cbe..a43327300aaae6c5adcbc28aefce5cb8c5609c6c 100644 (file)
@@ -59,6 +59,11 @@ nir_can_move_instr(nir_instr *instr, nir_move_options options)
       return true;
    }
 
+   if ((options & nir_move_copies) && instr->type == nir_instr_type_alu &&
+       nir_instr_as_alu(instr)->op == nir_op_mov) {
+      return true;
+   }
+
    if ((options & nir_move_comparisons) && instr->type == nir_instr_type_alu &&
        nir_alu_instr_is_comparison(nir_instr_as_alu(instr))) {
       return true;