summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-03-20 15:44:16 -0700
committerJason Ekstrand <[email protected]>2018-04-10 19:28:49 -0700
commitae3a856c34e348f721c2d647999813801b5eb33c (patch)
tree32cf54ecff7a663d35528bde0493814773a8c6e8
parented9463815644c85c124c72111d96e256db2986b4 (diff)
nir/lower_atomics: Rework the main walker loop a bit
This replaces some "if (...} { }" with "if (...) continue;" to reduce nesting depth and makes nir_metadata_preserve conditional on progress for the given impl. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
-rw-r--r--src/compiler/nir/nir_lower_atomics.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/compiler/nir/nir_lower_atomics.c b/src/compiler/nir/nir_lower_atomics.c
index 6b046bc426e..ee66aa3d7d5 100644
--- a/src/compiler/nir/nir_lower_atomics.c
+++ b/src/compiler/nir/nir_lower_atomics.c
@@ -183,18 +183,26 @@ 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,
- use_binding_as_idx);
- }
+ 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,
+ use_binding_as_idx);
}
+ }
+ if (impl_progress) {
nir_metadata_preserve(function->impl, nir_metadata_block_index |
nir_metadata_dominance);
+ progress = true;
}
}