[Mesa-dev] [PATCH 04/11] nir: make use of new nir_cf_list_clone_and_reinsert() helper

Thomas Helland thomashelland90 at gmail.com
Tue Dec 4 06:29:49 UTC 2018


Den tir. 20. nov. 2018 kl. 09:15 skrev Timothy Arceri <tarceri at itsqueeze.com>:
>
> ---
>  src/compiler/nir/nir_opt_loop_unroll.c | 74 ++++++++++----------------
>  1 file changed, 28 insertions(+), 46 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_loop_unroll.c b/src/compiler/nir/nir_opt_loop_unroll.c
> index 0e9966320b..935429add4 100644
> --- a/src/compiler/nir/nir_opt_loop_unroll.c
> +++ b/src/compiler/nir/nir_opt_loop_unroll.c
> @@ -169,32 +169,22 @@ simple_unroll(nir_loop *loop)
>        _mesa_hash_table_create(NULL, _mesa_hash_pointer,
>                                _mesa_key_pointer_equal);
>
> -   /* Clone the loop header */
> -   nir_cf_list cloned_header;
> -   nir_cf_list_clone(&cloned_header, &lp_header, loop->cf_node.parent,
> -                     remap_table);
> -
> -   /* Insert cloned loop header before the loop */
> -   nir_cf_reinsert(&cloned_header, nir_before_cf_node(&loop->cf_node));
> -
> -   /* Temp list to store the cloned loop body as we unroll */
> -   nir_cf_list unrolled_lp_body;
> +   /* Clone the loop header and insert before the loop */
> +   nir_cf_list_clone_and_reinsert(&lp_header, loop->cf_node.parent,
> +                                  nir_before_cf_node(&loop->cf_node),
> +                                  remap_table);
>
>     /* Clone loop header and append to the loop body */

^ Leftover comment?

Apart from that, patches 1 to 4 are

Reviewed-by: Thomas Helland <thomashelland90 at gmail.com>

>     for (unsigned i = 0; i < loop->info->max_trip_count; i++) {
> -      /* Clone loop body */
> -      nir_cf_list_clone(&unrolled_lp_body, &loop_body, loop->cf_node.parent,
> -                        remap_table);
> -
> -      /* Insert unrolled loop body before the loop */
> -      nir_cf_reinsert(&unrolled_lp_body, nir_before_cf_node(&loop->cf_node));
> -
> -      /* Clone loop header */
> -      nir_cf_list_clone(&cloned_header, &lp_header, loop->cf_node.parent,
> -                        remap_table);
> -
> -      /* Insert loop header after loop body */
> -      nir_cf_reinsert(&cloned_header, nir_before_cf_node(&loop->cf_node));
> +      /* Clone loop body and insert before the loop */
> +      nir_cf_list_clone_and_reinsert(&loop_body, loop->cf_node.parent,
> +                                     nir_before_cf_node(&loop->cf_node),
> +                                     remap_table);
> +
> +      /* Clone loop header and insert after loop body */
> +      nir_cf_list_clone_and_reinsert(&lp_header, loop->cf_node.parent,
> +                                     nir_before_cf_node(&loop->cf_node),
> +                                     remap_table);
>     }
>
>     /* Remove the break from the loop terminator and add instructions from
> @@ -207,11 +197,9 @@ simple_unroll(nir_loop *loop)
>                    nir_after_block(limiting_term->break_block));
>
>     /* Clone so things get properly remapped */
> -   nir_cf_list cloned_break_list;
> -   nir_cf_list_clone(&cloned_break_list, &break_list, loop->cf_node.parent,
> -                     remap_table);
> -
> -   nir_cf_reinsert(&cloned_break_list, nir_before_cf_node(&loop->cf_node));
> +   nir_cf_list_clone_and_reinsert(&break_list, loop->cf_node.parent,
> +                                  nir_before_cf_node(&loop->cf_node),
> +                                  remap_table);
>
>     /* Remove the loop */
>     nir_cf_node_remove(&loop->cf_node);
> @@ -397,16 +385,14 @@ complex_unroll(nir_loop *loop, nir_loop_terminator *unlimit_term,
>     nir_cf_list cloned_header;
>
>     for (unsigned i = 0; i < num_times_to_clone; i++) {
> -      /* Clone loop header */
> -      nir_cf_list_clone(&cloned_header, &lp_header, loop->cf_node.parent,
> -                        remap_table);
>
>        nir_cursor cursor =
>           get_complex_unroll_insert_location(unroll_loc,
>                                              unlimit_term->continue_from_then);
>
> -      /* Insert cloned loop header */
> -      nir_cf_reinsert(&cloned_header, cursor);
> +      /* Clone loop header and insert in if branch */
> +      nir_cf_list_clone_and_reinsert(&lp_header, loop->cf_node.parent,
> +                                     cursor, remap_table);
>
>        cursor =
>           get_complex_unroll_insert_location(unroll_loc,
> @@ -432,28 +418,24 @@ complex_unroll(nir_loop *loop, nir_loop_terminator *unlimit_term,
>     if (!limiting_term_second) {
>        assert(unroll_loc->type == nir_cf_node_if);
>
> -      nir_cf_list_clone(&cloned_header, &lp_header, loop->cf_node.parent,
> -                        remap_table);
> -
>        nir_cursor cursor =
>           get_complex_unroll_insert_location(unroll_loc,
>                                              unlimit_term->continue_from_then);
>
> -      /* Insert cloned loop header */
> -      nir_cf_reinsert(&cloned_header, cursor);
> -
> -      /* Clone so things get properly remapped, and insert break block from
> -       * the limiting terminator.
> -       */
> -      nir_cf_list cloned_break_blk;
> -      nir_cf_list_clone(&cloned_break_blk, &limit_break_list,
> -                        loop->cf_node.parent, remap_table);
> +      /* Clone loop header and insert in if branch */
> +      nir_cf_list_clone_and_reinsert(&lp_header, loop->cf_node.parent,
> +                                     cursor, remap_table);
>
>        cursor =
>           get_complex_unroll_insert_location(unroll_loc,
>                                              unlimit_term->continue_from_then);
>
> -      nir_cf_reinsert(&cloned_break_blk, cursor);
> +      /* Clone so things get properly remapped, and insert break block from
> +       * the limiting terminator.
> +       */
> +      nir_cf_list_clone_and_reinsert(&limit_break_list, loop->cf_node.parent,
> +                                     cursor, remap_table);
> +
>        nir_cf_delete(&limit_break_list);
>     }
>
> --
> 2.19.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list