summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2017-02-24 15:45:09 -0800
committerMatt Turner <[email protected]>2017-03-23 14:34:43 -0700
commita539e05d00d94d8ea1d73327e9adf4d2606534d5 (patch)
tree56ae01f11a3fc2977ed1f0c526159b955d3b05bb /src/compiler
parent5a7e4ae23d686566aee38290bc87f9ceee927d5b (diff)
nir: Return progress from nir_lower_to_source_mods().
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir.h2
-rw-r--r--src/compiler/nir/nir_lower_to_source_mods.c33
2 files changed, 29 insertions, 6 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 44396bcdc36..ddfd809e237 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2542,7 +2542,7 @@ void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *option
void nir_lower_atomics(nir_shader *shader,
const struct gl_shader_program *shader_program);
-void nir_lower_to_source_mods(nir_shader *shader);
+bool nir_lower_to_source_mods(nir_shader *shader);
bool nir_lower_gs_intrinsics(nir_shader *shader);
diff --git a/src/compiler/nir/nir_lower_to_source_mods.c b/src/compiler/nir/nir_lower_to_source_mods.c
index 69502d9b54c..077ca53704f 100644
--- a/src/compiler/nir/nir_lower_to_source_mods.c
+++ b/src/compiler/nir/nir_lower_to_source_mods.c
@@ -36,6 +36,8 @@
static bool
nir_lower_to_source_mods_block(nir_block *block)
{
+ bool progress = false;
+
nir_foreach_instr(instr, block) {
if (instr->type != nir_instr_type_alu)
continue;
@@ -91,6 +93,8 @@ nir_lower_to_source_mods_block(nir_block *block)
if (list_empty(&parent->dest.dest.ssa.uses) &&
list_empty(&parent->dest.dest.ssa.if_uses))
nir_instr_remove(&parent->instr);
+
+ progress = true;
}
switch (alu->op) {
@@ -161,6 +165,7 @@ nir_lower_to_source_mods_block(nir_block *block)
continue;
alu->dest.saturate = true;
+ progress = true;
nir_foreach_use(child_src, &alu->dest.dest.ssa) {
assert(child_src->is_ssa);
@@ -176,17 +181,35 @@ nir_lower_to_source_mods_block(nir_block *block)
}
}
- return true;
+ return progress;
}
-void
+static bool
+nir_lower_to_source_mods_impl(nir_function_impl *impl)
+{
+ bool progress = false;
+
+ nir_foreach_block(block, impl) {
+ progress |= nir_lower_to_source_mods_block(block);
+ }
+
+ if (progress)
+ nir_metadata_preserve(impl, nir_metadata_block_index |
+ nir_metadata_dominance);
+
+ return progress;
+}
+
+bool
nir_lower_to_source_mods(nir_shader *shader)
{
+ bool progress = false;
+
nir_foreach_function(function, shader) {
if (function->impl) {
- nir_foreach_block(block, function->impl) {
- nir_lower_to_source_mods_block(block);
- }
+ progress |= nir_lower_to_source_mods_impl(function->impl);
}
}
+
+ return progress;
}