<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jul 5, 2018 at 12:55 PM, Caio Marcelo de Oliveira Filho <span dir="ltr"><<a href="mailto:caio.oliveira@intel.com" target="_blank">caio.oliveira@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, Jul 04, 2018 at 09:55:26AM -0700, Jason Ekstrand wrote:<br>
> Removes an instruction from one place and inserts it at another while<br>
> working around a weird cursor corner-case.<br>
<br>
</span>Is the weird corner case the move to the same place case?<span class=""><br></span></blockquote><div><br></div><div>Yes<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> --- a/src/compiler/nir/nir.c<br>
> +++ b/src/compiler/nir/nir.c<br>
> @@ -845,6 +845,21 @@ nir_instr_insert(nir_cursor cursor, nir_instr *instr)<br>
>        nir_handle_add_jump(instr-><wbr>block);<br>
>  }<br>
>  <br>
> +void<br>
> +nir_instr_move(nir_cursor cursor, nir_instr *instr)<br>
> +{<br>
> +   /* If the cursor happens to refer to this instruction (either before or<br>
> +    * after), don't do anything.<br>
> +    */<br>
> +   if ((cursor.option == nir_cursor_before_instr ||<br>
> +        cursor.option == nir_cursor_after_instr) &&<br>
> +       cursor.instr == instr)<br>
> +      return;<br>
<br>
</span>Should we also consider the block-based cursor options here? Moving<br>
the first instruction of a block before that block<br>
(nir_cursor_before_block), etc.<br></blockquote><div><br></div><div>That should be fine as-is as nir_instr_insert should do the right thing.  The reason the cursor.instr == instr case is a problem is because you can't insert an instruction relative to itself.</div><div><br></div><div>--Jason<br></div></div></div></div>