struct split_var_copies_state {
void *mem_ctx;
void *dead_ctx;
+ bool progress;
};
/* Recursively constructs deref chains to split a copy instruction into
* remove the old one later.
*/
nir_instr_insert_after(&old_copy->instr, &new_copy->instr);
+ state->progress = true;
}
break;
return true;
}
-static void
+static bool
split_var_copies_impl(nir_function_impl *impl)
{
struct split_var_copies_state state;
state.mem_ctx = ralloc_parent(impl);
state.dead_ctx = ralloc_context(NULL);
+ state.progress = false;
nir_foreach_block(impl, split_var_copies_block, &state);
ralloc_free(state.dead_ctx);
+
+ return state.progress;
}
-void
+bool
nir_split_var_copies(nir_shader *shader)
{
+ bool progress = false;
+
nir_foreach_overload(shader, overload) {
if (overload->impl)
- split_var_copies_impl(overload->impl);
+ progress = split_var_copies_impl(overload->impl) || progress;
}
+
+ return progress;
}