<div dir="ltr"><div>3 and 4 are</div><div><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 6, 2018 at 9:08 PM Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Reviewed-by: Thomas Helland <<a href="mailto:thomashelland90@gmail.com" target="_blank">thomashelland90@gmail.com</a>><br>
---<br>
src/compiler/nir/nir_opt_loop_unroll.c | 76 ++++++++++----------------<br>
1 file changed, 28 insertions(+), 48 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_opt_loop_unroll.c b/src/compiler/nir/nir_opt_loop_unroll.c<br>
index 0e9966320b..c267c185b6 100644<br>
--- a/src/compiler/nir/nir_opt_loop_unroll.c<br>
+++ b/src/compiler/nir/nir_opt_loop_unroll.c<br>
@@ -169,32 +169,21 @@ simple_unroll(nir_loop *loop)<br>
_mesa_hash_table_create(NULL, _mesa_hash_pointer,<br>
_mesa_key_pointer_equal);<br>
<br>
- /* Clone the loop header */<br>
- nir_cf_list cloned_header;<br>
- nir_cf_list_clone(&cloned_header, &lp_header, loop->cf_node.parent,<br>
- remap_table);<br>
+ /* Clone the loop header and insert before the loop */<br>
+ nir_cf_list_clone_and_reinsert(&lp_header, loop->cf_node.parent,<br>
+ nir_before_cf_node(&loop->cf_node),<br>
+ remap_table);<br>
<br>
- /* Insert cloned loop header before the loop */<br>
- nir_cf_reinsert(&cloned_header, nir_before_cf_node(&loop->cf_node));<br>
-<br>
- /* Temp list to store the cloned loop body as we unroll */<br>
- nir_cf_list unrolled_lp_body;<br>
-<br>
- /* Clone loop header and append to the loop body */<br>
for (unsigned i = 0; i < loop->info->max_trip_count; i++) {<br>
- /* Clone loop body */<br>
- nir_cf_list_clone(&unrolled_lp_body, &loop_body, loop->cf_node.parent,<br>
- remap_table);<br>
-<br>
- /* Insert unrolled loop body before the loop */<br>
- nir_cf_reinsert(&unrolled_lp_body, nir_before_cf_node(&loop->cf_node));<br>
-<br>
- /* Clone loop header */<br>
- nir_cf_list_clone(&cloned_header, &lp_header, loop->cf_node.parent,<br>
- remap_table);<br>
-<br>
- /* Insert loop header after loop body */<br>
- nir_cf_reinsert(&cloned_header, nir_before_cf_node(&loop->cf_node));<br>
+ /* Clone loop body and insert before the loop */<br>
+ nir_cf_list_clone_and_reinsert(&loop_body, loop->cf_node.parent,<br>
+ nir_before_cf_node(&loop->cf_node),<br>
+ remap_table);<br>
+<br>
+ /* Clone loop header and insert after loop body */<br>
+ nir_cf_list_clone_and_reinsert(&lp_header, loop->cf_node.parent,<br>
+ nir_before_cf_node(&loop->cf_node),<br>
+ remap_table);<br>
}<br>
<br>
/* Remove the break from the loop terminator and add instructions from<br>
@@ -207,11 +196,9 @@ simple_unroll(nir_loop *loop)<br>
nir_after_block(limiting_term->break_block));<br>
<br>
/* Clone so things get properly remapped */<br>
- nir_cf_list cloned_break_list;<br>
- nir_cf_list_clone(&cloned_break_list, &break_list, loop->cf_node.parent,<br>
- remap_table);<br>
-<br>
- nir_cf_reinsert(&cloned_break_list, nir_before_cf_node(&loop->cf_node));<br>
+ nir_cf_list_clone_and_reinsert(&break_list, loop->cf_node.parent,<br>
+ nir_before_cf_node(&loop->cf_node),<br>
+ remap_table);<br>
<br>
/* Remove the loop */<br>
nir_cf_node_remove(&loop->cf_node);<br>
@@ -394,19 +381,16 @@ complex_unroll(nir_loop *loop, nir_loop_terminator *unlimit_term,<br>
<br>
/* Temp lists to store the cloned loop as we unroll */<br>
nir_cf_list unrolled_lp_body;<br>
- nir_cf_list cloned_header;<br>
<br>
for (unsigned i = 0; i < num_times_to_clone; i++) {<br>
- /* Clone loop header */<br>
- nir_cf_list_clone(&cloned_header, &lp_header, loop->cf_node.parent,<br>
- remap_table);<br>
<br>
nir_cursor cursor =<br>
get_complex_unroll_insert_location(unroll_loc,<br>
unlimit_term->continue_from_then);<br>
<br>
- /* Insert cloned loop header */<br>
- nir_cf_reinsert(&cloned_header, cursor);<br>
+ /* Clone loop header and insert in if branch */<br>
+ nir_cf_list_clone_and_reinsert(&lp_header, loop->cf_node.parent,<br>
+ cursor, remap_table);<br>
<br>
cursor =<br>
get_complex_unroll_insert_location(unroll_loc,<br>
@@ -432,28 +416,24 @@ complex_unroll(nir_loop *loop, nir_loop_terminator *unlimit_term,<br>
if (!limiting_term_second) {<br>
assert(unroll_loc->type == nir_cf_node_if);<br>
<br>
- nir_cf_list_clone(&cloned_header, &lp_header, loop->cf_node.parent,<br>
- remap_table);<br>
-<br>
nir_cursor cursor =<br>
get_complex_unroll_insert_location(unroll_loc,<br>
unlimit_term->continue_from_then);<br>
<br>
- /* Insert cloned loop header */<br>
- nir_cf_reinsert(&cloned_header, cursor);<br>
-<br>
- /* Clone so things get properly remapped, and insert break block from<br>
- * the limiting terminator.<br>
- */<br>
- nir_cf_list cloned_break_blk;<br>
- nir_cf_list_clone(&cloned_break_blk, &limit_break_list,<br>
- loop->cf_node.parent, remap_table);<br>
+ /* Clone loop header and insert in if branch */<br>
+ nir_cf_list_clone_and_reinsert(&lp_header, loop->cf_node.parent,<br>
+ cursor, remap_table);<br>
<br>
cursor =<br>
get_complex_unroll_insert_location(unroll_loc,<br>
unlimit_term->continue_from_then);<br>
<br>
- nir_cf_reinsert(&cloned_break_blk, cursor);<br>
+ /* Clone so things get properly remapped, and insert break block from<br>
+ * the limiting terminator.<br>
+ */<br>
+ nir_cf_list_clone_and_reinsert(&limit_break_list, loop->cf_node.parent,<br>
+ cursor, remap_table);<br>
+<br>
nir_cf_delete(&limit_break_list);<br>
}<br>
<br>
-- <br>
2.19.2<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>