<div dir="ltr"><div>LGTM<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 22, 2017 at 8:43 AM, 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>
 src/compiler/nir/nir.h     | 2 +-<br>
 src/compiler/nir/nir_from_ssa.<wbr>c | 21 ++++++++++++++-------<br>
 2 files changed, 15 insertions(+), 8 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..1aa3550 100644<br>
<span class="">--- 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>
</span>@@ -503,6 +504,7 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state)<br>
    nir_instr *parent_instr = def->parent_instr;<br>
    nir_instr_remove(parent_instr)<wbr>;<br>
    ralloc_steal(state->dead_ctx, parent_instr);<br>
<span class="">+Â Â Â state->progress = true;<br>
</span>Â Â Â Â return true;<br>
  }<br>
<br>
@@ -514,14 +516,14 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state)<br>
  nir_dest *dest = exec_node_data(nir_dest, def, ssa);<br>
<br>
  nir_instr_rewrite_dest(state-><wbr>instr, dest, nir_dest_for_reg(reg));<br>
-<br>
<span class="">+Â Â state->progress = true;<br>
</span>Â Â return true;<br>
<span class="">Â }<br>
<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>
 resolve_registers_block(nir_<wbr>block *block, struct from_ssa_state *state)<br>
 {<br>
  nir_foreach_instr_safe(instr, block) {<br>
</span>@@ -531,11 +533,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>
+Â Â Â Â Â state->progress = true;<br>
    }<br>
  }<br>
</span><span class="">Â Â state->instr = NULL;<br>
-<br>
-Â Â return true;<br>
 }<br>
<br>
 static void<br>
</span>@@ -756,7 +757,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 +767,7 @@ nir_convert_from_ssa_impl(nir_<wbr>function_impl *impl, bool phi_webs_only)<br>
<span class="">Â Â 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>
</span>@@ -804,15 +806,20 @@ nir_convert_from_ssa_impl(nir_<wbr>function_impl *impl, bool phi_webs_only)<br>
<div class="HOEnZb"><div class="h5">Â Â /* 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>
+Â Â return state.progress;<br>
 }<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>