<p dir="ltr"><br>
On May 26, 2016 9:32 PM, "Connor Abbott" <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>> wrote:<br>
><br>
> On Wed, May 25, 2016 at 1:53 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
> > Now that we have the better nir_foreach_block macro, there's no reason to<br>
> > use the archaic block version for everything.<br>
> > ---<br>
> > src/compiler/nir/nir_inline_functions.c | 53 ++++++++++++++++-----------------<br>
> > 1 file changed, 25 insertions(+), 28 deletions(-)<br>
> ><br>
> > diff --git a/src/compiler/nir/nir_inline_functions.c b/src/compiler/nir/nir_inline_functions.c<br>
> > index 4641e8c..e124a77 100644<br>
> > --- a/src/compiler/nir/nir_inline_functions.c<br>
> > +++ b/src/compiler/nir/nir_inline_functions.c<br>
> > @@ -27,40 +27,36 @@<br>
> ><br>
> > static bool inline_function_impl(nir_function_impl *impl, struct set *inlined);<br>
> ><br>
> > -static bool<br>
> > -rewrite_param_derefs_block(nir_block *block, nir_call_instr *call)<br>
> > +static void<br>
> > +rewrite_param_derefs(nir_instr *instr, nir_call_instr *call)<br>
> > {<br>
> > - nir_foreach_instr_safe(instr, block) {<br>
> > - if (instr->type != nir_instr_type_intrinsic)<br>
> > - continue;<br>
> > -<br>
> > - nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);<br>
> > + if (instr->type != nir_instr_type_intrinsic)<br>
> > + return;<br>
> ><br>
> > - for (unsigned i = 0;<br>
> > - i < nir_intrinsic_infos[intrin->intrinsic].num_variables; i++) {<br>
> > - if (intrin->variables[i]->var->data.mode != nir_var_param)<br>
> > - continue;<br>
> > + nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);<br>
> ><br>
> > - int param_idx = intrin->variables[i]->var->data.location;<br>
> > + for (unsigned i = 0;<br>
> > + i < nir_intrinsic_infos[intrin->intrinsic].num_variables; i++) {<br>
> > + if (intrin->variables[i]->var->data.mode != nir_var_param)<br>
> > + continue;<br>
> ><br>
> > - nir_deref_var *call_deref;<br>
> > - if (param_idx >= 0) {<br>
> > - assert(param_idx < call->callee->num_params);<br>
> > - call_deref = call->params[param_idx];<br>
> > - } else {<br>
> > - call_deref = call->return_deref;<br>
> > - }<br>
> > - assert(call_deref);<br>
> > + int param_idx = intrin->variables[i]->var->data.location;<br>
> ><br>
> > - nir_deref_var *new_deref = nir_deref_as_var(nir_copy_deref(intrin, &call_deref->deref));<br>
> > - nir_deref *new_tail = nir_deref_tail(&new_deref->deref);<br>
> > - new_tail->child = intrin->variables[i]->deref.child;<br>
> > - ralloc_steal(new_tail, new_tail->child);<br>
> > - intrin->variables[i] = new_deref;<br>
> > + nir_deref_var *call_deref;<br>
> > + if (param_idx >= 0) {<br>
> > + assert(param_idx < call->callee->num_params);<br>
> > + call_deref = call->params[param_idx];<br>
> > + } else {<br>
> > + call_deref = call->return_deref;<br>
> > }<br>
> > - }<br>
> > + assert(call_deref);<br>
> ><br>
> > - return true;<br>
> > + nir_deref_var *new_deref = nir_deref_as_var(nir_copy_deref(intrin, &call_deref->deref));<br>
> > + nir_deref *new_tail = nir_deref_tail(&new_deref->deref);<br>
> > + new_tail->child = intrin->variables[i]->deref.child;<br>
> > + ralloc_steal(new_tail, new_tail->child);<br>
> > + intrin->variables[i] = new_deref;<br>
> > + }<br>
> > }<br>
> ><br>
> > static void<br>
> > @@ -184,7 +180,8 @@ inline_functions_block(nir_block *block, nir_builder *b,<br>
> > }<br>
> ><br>
> > nir_foreach_block(block, callee_copy) {<br>
> > - rewrite_param_derefs_block(block, call);<br>
> > + nir_foreach_instr_safe(instr, block)<br>
> > + rewrite_param_derefs(instr, call);<br>
><br>
> I realize this was in the original, but I don't think we need the<br>
> _safe variant here, since we don't remove/add instructions.</p>
<p dir="ltr">Yeah, I can get rid of it.</p>
<p dir="ltr">> > }<br>
> ><br>
> > /* Pluck the body out of the function and place it here */<br>
> > --<br>
> > 2.5.0.400.gff86faf<br>
> ><br>
> > _______________________________________________<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">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>