[Mesa-dev] [RFC v1 17/38] nir/lower_atomics: Rework the main walker loop a bit

Jason Ekstrand jason at jlekstrand.net
Wed Mar 21 05:54:51 UTC 2018


This replaces some "if (...} { }" with "if (...) continue;" to reduce
nesting depth and makes nir_metadata_preserve conditional on progress
for the given impl.
---
 src/compiler/nir/nir_lower_atomics.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/compiler/nir/nir_lower_atomics.c b/src/compiler/nir/nir_lower_atomics.c
index bdab4b8..2287517 100644
--- a/src/compiler/nir/nir_lower_atomics.c
+++ b/src/compiler/nir/nir_lower_atomics.c
@@ -179,17 +179,25 @@ nir_lower_atomics(nir_shader *shader,
    bool progress = false;
 
    nir_foreach_function(function, shader) {
-      if (function->impl) {
-         nir_foreach_block(block, function->impl) {
-            nir_foreach_instr_safe(instr, block) {
-               if (instr->type == nir_instr_type_intrinsic)
-                  progress |= lower_instr(nir_instr_as_intrinsic(instr),
-                                          shader_program, shader);
-            }
+      if (!function->impl)
+         continue;
+
+      bool impl_progress = false;
+
+      nir_foreach_block(block, function->impl) {
+         nir_foreach_instr_safe(instr, block) {
+            if (instr->type != nir_instr_type_intrinsic)
+               continue;
+
+            impl_progress |= lower_instr(nir_instr_as_intrinsic(instr),
+                                         shader_program, shader);
          }
+      }
 
+      if (impl_progress) {
          nir_metadata_preserve(function->impl, nir_metadata_block_index |
                                                nir_metadata_dominance);
+         progress = true;
       }
    }
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list