nir_to_tgsi: Enable nir_opt_move.
authorEmma Anholt <emma@anholt.net>
Wed, 8 Dec 2021 19:33:28 +0000 (11:33 -0800)
committerMarge Bot <emma+marge@anholt.net>
Thu, 9 Dec 2021 22:15:53 +0000 (22:15 +0000)
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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14096>

src/gallium/auxiliary/nir/nir_to_tgsi.c

index 69ff540..1041132 100644 (file)
@@ -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.