Mesa (master): radeonsi: reorder NIR optimizations

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 5 20:56:39 UTC 2020


Module: Mesa
Branch: master
Commit: 47beee2eb3f1bf73d20e9695cfc06d50193ba6ca
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=47beee2eb3f1bf73d20e9695cfc06d50193ba6ca

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Jul  3 22:05:18 2020 -0400

radeonsi: reorder NIR optimizations

Based on https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5668

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5750>

---

 src/gallium/drivers/radeonsi/si_shader_nir.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 395305f7f8a..ad9ebd65341 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -743,28 +743,32 @@ static void si_nir_opts(struct nir_shader *nir)
 {
    bool progress;
 
+   NIR_PASS_V(nir, nir_lower_vars_to_ssa);
+   NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL, NULL);
+   NIR_PASS_V(nir, nir_lower_phis_to_scalar);
+
    do {
       progress = false;
-
-      NIR_PASS_V(nir, nir_lower_vars_to_ssa);
+      bool lower_alu_to_scalar = false;
+      bool lower_phis_to_scalar = false;
 
       NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
       NIR_PASS(progress, nir, nir_opt_dead_write_vars);
 
-      NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL, NULL);
-      NIR_PASS_V(nir, nir_lower_phis_to_scalar);
-
+      NIR_PASS(lower_alu_to_scalar, nir, nir_opt_trivial_continues);
       /* (Constant) copy propagation is needed for txf with offsets. */
       NIR_PASS(progress, nir, nir_copy_prop);
       NIR_PASS(progress, nir, nir_opt_remove_phis);
       NIR_PASS(progress, nir, nir_opt_dce);
-      if (nir_opt_trivial_continues(nir)) {
-         progress = true;
-         NIR_PASS(progress, nir, nir_copy_prop);
-         NIR_PASS(progress, nir, nir_opt_dce);
-      }
-      NIR_PASS(progress, nir, nir_opt_if, true);
+      NIR_PASS(lower_phis_to_scalar, nir, nir_opt_if, true);
       NIR_PASS(progress, nir, nir_opt_dead_cf);
+
+      if (lower_alu_to_scalar)
+         NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL, NULL);
+      if (lower_phis_to_scalar)
+         NIR_PASS_V(nir, nir_lower_phis_to_scalar);
+      progress |= lower_alu_to_scalar | lower_phis_to_scalar;
+
       NIR_PASS(progress, nir, nir_opt_cse);
       NIR_PASS(progress, nir, nir_opt_peephole_select, 8, true, true);
 



More information about the mesa-commit mailing list