aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorRhys Perry <[email protected]>2019-10-14 17:15:04 +0100
committerMarge Bot <[email protected]>2020-01-14 13:56:45 +0000
commitd8e05edbd93e544530ae616fd239c4731e8c68bc (patch)
tree0515c7323ac8fc41b368b5a52574693c3200c8ae /src/compiler
parent04fac72ec77f9a19e56ec95f7a0b857f85438ab3 (diff)
nir/sink,nir/move: move/sink nir_op_mov
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 <[email protected]> Acked-by: Jason Ekstrand <[email protected]> (v1) Acked-by: Rob Clark <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2420> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2420>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir.h1
-rw-r--r--src/compiler/nir/nir_opt_sink.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 4b6294d7bea..a8e4184f1d5 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -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);
diff --git a/src/compiler/nir/nir_opt_sink.c b/src/compiler/nir/nir_opt_sink.c
index e68ad9cd607..a43327300aa 100644
--- a/src/compiler/nir/nir_opt_sink.c
+++ b/src/compiler/nir/nir_opt_sink.c
@@ -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;