<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 16, 2017 at 2:18 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>
 src/compiler/nir/nir.h          |  2 +-<br>
 src/compiler/nir/nir_from_ssa.<wbr>c | 21 +++++++++++++++------<br>
 2 files changed, 16 insertions(+), 7 deletions(-)<br>
<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>
index d2646c6..07fcceb 100644<br>
--- a/src/compiler/nir/nir_from_<wbr>ssa.c<br>
+++ b/src/compiler/nir/nir_from_<wbr>ssa.c<br>
@@ -524,18 +524,21 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state)<br>
 static bool<br>
 resolve_registers_block(nir_<wbr>block *block, struct from_ssa_state *state)<br>
 {<br>
+   bool progress = false;<br>
+<br>
    nir_foreach_instr_safe(instr, block) {<br>
       state->instr = instr;<br>
-      nir_foreach_ssa_def(instr, rewrite_ssa_def, state);<br>
+      progress |= nir_foreach_ssa_def(instr, rewrite_ssa_def, state);<br></blockquote><div><br></div><div>We can't trust the return value here.  rewrite_ssa_def *always* returns true regardless of whether or not it works.  (It kind-of has to thanks to the way NIR's function pointer based iteration functions work.)  I think we need to have a progress boolean in the state structure for this pass.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
       if (instr->type == nir_instr_type_phi) {<br>
          nir_instr_remove(instr);<br>
          ralloc_steal(state->dead_ctx, instr);<br>
+         progress = true;<br>
       }<br>
    }<br>
    state->instr = NULL;<br>
<br>
-   return true;<br>
+   return progress;<br>
 }<br>
<br>
 static void<br>
@@ -756,10 +759,11 @@ resolve_parallel_copies_block(<wbr>nir_block *block, struct from_ssa_state *state)<br>
    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>
+   bool progress = false;<br>
<br>
    nir_builder_init(&state.<wbr>builder, impl);<br>
    state.dead_ctx = ralloc_context(NULL);<br>
@@ -791,7 +795,7 @@ nir_convert_from_ssa_impl(nir_<wbr>function_impl *impl, bool phi_webs_only)<br>
    }<br>
<br>
    nir_foreach_block(block, impl) {<br>
-      resolve_registers_block(block, &state);<br>
+      progress |= resolve_registers_block(block, &state);<br>
    }<br>
<br>
    nir_foreach_block(block, impl) {<br>
@@ -804,15 +808,20 @@ nir_convert_from_ssa_impl(nir_<wbr>function_impl *impl, bool phi_webs_only)<br>
    /* 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 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>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
2.10.2<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>