summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-09-13 15:14:28 -0700
committerKenneth Graunke <[email protected]>2016-09-14 12:01:51 -0700
commit2d8a3fa7ea994ad02a40ff497109f966e3fcbeec (patch)
tree59bb6bdd47d2cd9120af0ffeff1bcc9e0b79107b /src/compiler
parent32630e211e60a2b41388d403cfbd4f43344d8590 (diff)
nir: Report progress from nir_lower_phis_to_scalar.
Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir.h2
-rw-r--r--src/compiler/nir/nir_lower_phis_to_scalar.c20
2 files changed, 16 insertions, 6 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 3b3d6ae8393..94eae6d3037 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2413,7 +2413,7 @@ bool nir_lower_vec_to_movs(nir_shader *shader);
bool nir_lower_alu_to_scalar(nir_shader *shader);
void nir_lower_load_const_to_scalar(nir_shader *shader);
-void nir_lower_phis_to_scalar(nir_shader *shader);
+bool nir_lower_phis_to_scalar(nir_shader *shader);
void nir_lower_io_to_scalar(nir_shader *shader, nir_variable_mode mask);
void nir_lower_samplers(nir_shader *shader,
diff --git a/src/compiler/nir/nir_lower_phis_to_scalar.c b/src/compiler/nir/nir_lower_phis_to_scalar.c
index 9fd00cc784a..b12718f2732 100644
--- a/src/compiler/nir/nir_lower_phis_to_scalar.c
+++ b/src/compiler/nir/nir_lower_phis_to_scalar.c
@@ -166,6 +166,8 @@ static bool
lower_phis_to_scalar_block(nir_block *block,
struct lower_phis_to_scalar_state *state)
{
+ bool progress = false;
+
/* Find the last phi node in the block */
nir_phi_instr *last_phi = NULL;
nir_foreach_instr(instr, block) {
@@ -248,6 +250,8 @@ lower_phis_to_scalar_block(nir_block *block,
ralloc_steal(state->dead_ctx, phi);
nir_instr_remove(&phi->instr);
+ progress = true;
+
/* We're using the safe iterator and inserting all the newly
* scalarized phi nodes before their non-scalarized version so that's
* ok. However, we are also inserting vec operations after all of
@@ -258,13 +262,14 @@ lower_phis_to_scalar_block(nir_block *block,
break;
}
- return true;
+ return progress;
}
-static void
+static bool
lower_phis_to_scalar_impl(nir_function_impl *impl)
{
struct lower_phis_to_scalar_state state;
+ bool progress = false;
state.mem_ctx = ralloc_parent(impl);
state.dead_ctx = ralloc_context(NULL);
@@ -272,13 +277,14 @@ lower_phis_to_scalar_impl(nir_function_impl *impl)
_mesa_key_pointer_equal);
nir_foreach_block(block, impl) {
- lower_phis_to_scalar_block(block, &state);
+ progress = lower_phis_to_scalar_block(block, &state) || progress;
}
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
ralloc_free(state.dead_ctx);
+ return progress;
}
/** A pass that lowers vector phi nodes to scalar
@@ -288,11 +294,15 @@ lower_phis_to_scalar_impl(nir_function_impl *impl)
* instance, if one of the sources is a non-scalarizable vector, then we
* don't bother lowering because that would generate hard-to-coalesce movs.
*/
-void
+bool
nir_lower_phis_to_scalar(nir_shader *shader)
{
+ bool progress = false;
+
nir_foreach_function(function, shader) {
if (function->impl)
- lower_phis_to_scalar_impl(function->impl);
+ progress = lower_phis_to_scalar_impl(function->impl) || progress;
}
+
+ return progress;
}