From 5887768f48e4f5116642b48cd21cac93e1c52c97 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 8 Dec 2021 11:33:28 -0800 Subject: [PATCH] nir_to_tgsi: Enable nir_opt_move. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This moves some ops down to when they're needed, generally reducing the number of temps in use. It's not always a win -- sometimes you can end up moving a generator of a component used by a nir_op_vec down, which means that op's sources stay live while the vec (whose register likely gets coalesced with the ops creating it) is also live. But it's generally good. softpipe results: temps in affected programs: 18115 -> 18026 (-0.49%) imm in affected programs: 19 -> 22 (15.79%) r300 results: instructions in affected programs: 174 -> 178 (2.30%) vinst in affected programs: 156 -> 160 (2.56%) sinst in affected programs: 54 -> 50 (-7.41%) temps in affected programs: 2634 -> 2169 (-17.65%) Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/nir/nir_to_tgsi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index 69ff5401bc2..1041132039f 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -3147,6 +3147,12 @@ nir_to_tgsi(struct nir_shader *s, NIR_PASS_V(s, nir_opt_dce); } + nir_move_options move_all = + nir_move_const_undef | nir_move_load_ubo | nir_move_load_input | + nir_move_comparisons | nir_move_copies | nir_move_load_ssbo; + + NIR_PASS_V(s, nir_opt_move, move_all); + /* Only lower 32-bit floats. The only other modifier type officially * supported by TGSI is 32-bit integer negates, but even those are broken on * virglrenderer, so skip lowering all integer and f64 float mods.