[Mesa-dev] [PATCH 08/23] nir: Return progress from nir_lower_var_copies().

Matt Turner mattst88 at gmail.com
Thu Mar 16 21:18:05 UTC 2017


---
 src/compiler/nir/nir.h                  |  2 +-
 src/compiler/nir/nir_lower_var_copies.c | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index a67879b..1c792f1 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2354,7 +2354,7 @@ bool nir_inline_functions(nir_shader *shader);
 bool nir_propagate_invariant(nir_shader *shader);
 
 void nir_lower_var_copy_instr(nir_intrinsic_instr *copy, nir_shader *shader);
-void nir_lower_var_copies(nir_shader *shader);
+bool nir_lower_var_copies(nir_shader *shader);
 
 bool nir_lower_global_vars_to_local(nir_shader *shader);
 
diff --git a/src/compiler/nir/nir_lower_var_copies.c b/src/compiler/nir/nir_lower_var_copies.c
index 30d2835..6288bdc 100644
--- a/src/compiler/nir/nir_lower_var_copies.c
+++ b/src/compiler/nir/nir_lower_var_copies.c
@@ -154,10 +154,11 @@ nir_lower_var_copy_instr(nir_intrinsic_instr *copy, nir_shader *shader)
                         &copy->variables[1]->deref, shader);
 }
 
-static void
+static bool
 lower_var_copies_impl(nir_function_impl *impl)
 {
    nir_shader *shader = impl->function->shader;
+   bool progress = false;
 
    nir_foreach_block(block, impl) {
       nir_foreach_instr_safe(instr, block) {
@@ -171,19 +172,30 @@ lower_var_copies_impl(nir_function_impl *impl)
          nir_lower_var_copy_instr(copy, shader);
 
          nir_instr_remove(&copy->instr);
+         progress = true;
          ralloc_free(copy);
       }
    }
+
+   if (progress)
+      nir_metadata_preserve(impl, nir_metadata_block_index |
+                                  nir_metadata_dominance);
+
+   return progress;
 }
 
 /* Lowers every copy_var instruction in the program to a sequence of
  * load/store instructions.
  */
-void
+bool
 nir_lower_var_copies(nir_shader *shader)
 {
+   bool progress = false;
+
    nir_foreach_function(function, shader) {
       if (function->impl)
-         lower_var_copies_impl(function->impl);
+         progress |= lower_var_copies_impl(function->impl);
    }
+
+   return progress;
 }
-- 
2.10.2



More information about the mesa-dev mailing list