nir: Return progress from nir_lower_var_copies().
authorMatt Turner <mattst88@gmail.com>
Fri, 24 Feb 2017 23:34:40 +0000 (15:34 -0800)
committerMatt Turner <mattst88@gmail.com>
Thu, 23 Mar 2017 21:34:43 +0000 (14:34 -0700)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_var_copies.c

index d570ee74a45122ee947449b39cafc14b4a61faca..80efa063f31bf8a333c5f70d709704a529694e30 100644 (file)
@@ -2355,7 +2355,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);
 
index 30d28351d53a548238388a59efda6c909b26e45f..6288bdc465b14cd503fd5c9c44990e898621285c 100644 (file)
@@ -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;
 }