<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 21, 2017 at 4:59 PM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
Is this what you had in mind?<br></blockquote><div><br></div><div>More or less.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
src/compiler/nir/nir.h | 2 +-<br>
src/compiler/nir/nir_from_ssa.<wbr>c | 18 ++++++++++++------<br>
2 files changed, 13 insertions(+), 7 deletions(-)<br>
<span class=""><br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index db47699..0a127cd 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -2587,7 +2587,7 @@ void nir_convert_loop_to_lcssa(nir_<wbr>loop *loop);<br>
* registers. If false, convert all values (even those not involved in a phi<br>
* node) to registers.<br>
*/<br>
-void nir_convert_from_ssa(nir_<wbr>shader *shader, bool phi_webs_only);<br>
+bool nir_convert_from_ssa(nir_<wbr>shader *shader, bool phi_webs_only);<br>
<br>
bool nir_lower_phis_to_regs_block(<wbr>nir_block *block);<br>
bool nir_lower_ssa_defs_to_regs_<wbr>block(nir_block *block);<br>
diff --git a/src/compiler/nir/nir_from_<wbr>ssa.c b/src/compiler/nir/nir_from_<wbr>ssa.c<br>
</span>index d2646c6..9647d74 100644<br>
--- a/src/compiler/nir/nir_from_<wbr>ssa.c<br>
+++ b/src/compiler/nir/nir_from_<wbr>ssa.c<br>
@@ -41,6 +41,7 @@ struct from_ssa_state {<br>
bool phi_webs_only;<br>
struct hash_table *merge_node_table;<br>
nir_instr *instr;<br>
+ bool progress;<br>
};<br>
<br>
/* Returns true if a dominates b */<br>
@@ -521,7 +522,7 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state)<br>
/* Resolves ssa definitions to registers. While we're at it, we also<br>
* remove phi nodes.<br>
*/<br>
-static bool<br>
+static void<br>
<span class=""> resolve_registers_block(nir_<wbr>block *block, struct from_ssa_state *state)<br>
{<br>
</span> nir_foreach_instr_safe(instr, block) {<br>
@@ -531,11 +532,10 @@ resolve_registers_block(nir_<wbr>block *block, struct from_ssa_state *state)<br>
<span class=""> if (instr->type == nir_instr_type_phi) {<br>
nir_instr_remove(instr);<br>
ralloc_steal(state->dead_ctx, instr);<br>
</span>+ state->progress = true;<br></blockquote><div><br></div><div>We also need to set it to true in rewrite_ssa_def on lines 505 and 516.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""> }<br>
}<br>
state->instr = NULL;<br>
-<br>
</span>- return true;<br>
}<br>
<br>
static void<br>
@@ -756,7 +756,7 @@ resolve_parallel_copies_block(<wbr>nir_block *block, struct from_ssa_state *state)<br>
<span class=""> return true;<br>
}<br>
<br>
-static void<br>
+static bool<br>
nir_convert_from_ssa_impl(nir_<wbr>function_impl *impl, bool phi_webs_only)<br>
{<br>
struct from_ssa_state state;<br>
</span>@@ -766,6 +766,7 @@ nir_convert_from_ssa_impl(nir_<wbr>function_impl *impl, bool phi_webs_only)<br>
state.phi_webs_only = phi_webs_only;<br>
state.merge_node_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,<br>
_mesa_key_pointer_equal);<br>
+ state.progress = false;<br>
<br>
nir_foreach_block(block, impl) {<br>
add_parallel_copy_to_end_of_<wbr>block(block, state.dead_ctx);<br>
@@ -804,15 +805,20 @@ nir_convert_from_ssa_impl(nir_<wbr>function_impl *impl, bool phi_webs_only)<br>
<span class=""> /* Clean up dead instructions and the hash tables */<br>
_mesa_hash_table_destroy(<wbr>state.merge_node_table, NULL);<br>
ralloc_free(state.dead_ctx);<br>
</span>+ return state.progress;<br>
<div class="HOEnZb"><div class="h5"> }<br>
<br>
-void<br>
+bool<br>
nir_convert_from_ssa(nir_<wbr>shader *shader, bool phi_webs_only)<br>
{<br>
+ bool progress = false;<br>
+<br>
nir_foreach_function(function, shader) {<br>
if (function->impl)<br>
- nir_convert_from_ssa_impl(<wbr>function->impl, phi_webs_only);<br>
+ progress |= nir_convert_from_ssa_impl(<wbr>function->impl, phi_webs_only);<br>
}<br>
+<br>
+ return progress;<br>
}<br>
<br>
<br>
--<br>
2.10.2<br>
<br>
</div></div></blockquote></div><br></div></div>