Mesa (main): nir_to_tgsi: Enable nir_opt_move.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 10 13:56:25 UTC 2021


Module: Mesa
Branch: main
Commit: 5887768f48e4f5116642b48cd21cac93e1c52c97
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5887768f48e4f5116642b48cd21cac93e1c52c97

Author: Emma Anholt <emma at anholt.net>
Date:   Wed Dec  8 11:33:28 2021 -0800

nir_to_tgsi: Enable nir_opt_move.

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 at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14096>

---

 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.



More information about the mesa-commit mailing list