From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Robin Dapp <rdapp@linux.ibm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Richard Sandiford <richard.sandiford@arm.com>
Subject: Re: [PATCH] vect: Add bias parameter for partial vectorization
Date: Mon, 22 Nov 2021 14:55:08 +0800 [thread overview]
Message-ID: <3977d753-2bb4-3c47-22d2-b4948ddc38bd@linux.ibm.com> (raw)
In-Reply-To: <a700ae7b-fdb6-0acb-2204-9c6c7fd3afe0@linux.ibm.com>
Hi Robin,
on 2021/11/12 下午5:56, Robin Dapp wrote:
> Hi Kewen and Richard,
>
> the attached v3 addresses the comments to v2, among others:
>
> - Rename to load_store where appropriate.
> - Save the adjusted length as a separate control that is used instead
> of loop_len with a bias != 0 and added to the loop header.
> - Update the costs to reflect a bias.
>
> Bootstrap and regtest were fine on z15 and p9.
>
Nice! Some minor comments are inlined below.
> Regards
> Robin
>
>
> vll-v3.patch
>
...
> extern void expand_addsub_overflow (location_t, tree_code, tree, tree, tree,
> bool, bool, bool, bool, tree *);
> diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
> index 4988c93fdb6..931378820ac 100644
> --- a/gcc/tree-vect-loop-manip.c
> +++ b/gcc/tree-vect-loop-manip.c
> @@ -421,6 +421,7 @@ vect_maybe_permute_loop_masks (gimple_seq *seq, rgroup_controls *dest_rgm,
> static tree
> vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
> gimple_seq *preheader_seq,
> + gimple_seq *header_seq,
> gimple_stmt_iterator loop_cond_gsi,
> rgroup_controls *rgc, tree niters,
> tree niters_skip, bool might_wrap_p)
> @@ -436,7 +437,7 @@ vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
> tree length_limit = NULL_TREE;
> /* For length, we need length_limit to ensure length in range. */
> if (!use_masks_p)
> - length_limit = build_int_cst (compare_type, nitems_per_ctrl);
> + length_limit = build_int_cst (compare_type, nitems_per_ctrl);
>
Nit, seems like an unintentional change.
> /* Calculate the maximum number of item values that the rgroup
> handles in total, the number that it handles for each iteration
> @@ -560,8 +561,9 @@ vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
> {
> /* Previous controls will cover BIAS items. This control covers the
> next batch. */
> + tree bias_tree;
> poly_uint64 bias = nitems_per_ctrl * i;
> - tree bias_tree = build_int_cst (compare_type, bias);
> + bias_tree = build_int_cst (compare_type, bias);
>
Same as above.
> /* See whether the first iteration of the vector loop is known
> to have a full control. */
> @@ -664,6 +666,20 @@ vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
>
> vect_set_loop_control (loop, ctrl, init_ctrl, next_ctrl);
> }
> +
> + int partial_load_bias = LOOP_VINFO_PARTIAL_LOAD_STORE_BIAS (loop_vinfo);
> + if (partial_load_bias != 0
> + && partial_load_bias != VECT_PARTIAL_BIAS_UNSUPPORTED)
> + {
IIUC, we don't need to check VECT_PARTIAL_BIAS_UNSUPPORTED again? Since it's
at the stage of transformation, we have checked it before for sure?
> + tree adjusted_len = rgc->bias_adjusted_ctrl;
> + gassign *minus = gimple_build_assign (adjusted_len, MINUS_EXPR,
> + rgc->controls[0],
> + build_int_cst
> + (TREE_TYPE (rgc->controls[0]),
> + -partial_load_bias));
> + gimple_seq_add_stmt (header_seq, minus);
> + }
> +
> return next_ctrl;
> }
>
> @@ -744,6 +760,7 @@ vect_set_loop_condition_partial_vectors (class loop *loop,
> /* Set up all controls for this group. */
> test_ctrl = vect_set_loop_controls_directly (loop, loop_vinfo,
> &preheader_seq,
> + &header_seq,
> loop_cond_gsi, rgc,
> niters, niters_skip,
> might_wrap_p);
> diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
> index e94356d76e9..ceeb6920871 100644
> --- a/gcc/tree-vect-loop.c
> +++ b/gcc/tree-vect-loop.c
> @@ -1163,6 +1163,31 @@ vect_verify_loop_lens (loop_vec_info loop_vinfo)
> if (LOOP_VINFO_LENS (loop_vinfo).is_empty ())
> return false;
>
> + machine_mode len_load_mode = get_len_load_store_mode
> + (loop_vinfo->vector_mode, true).require ();
> + machine_mode len_store_mode = get_len_load_store_mode
> + (loop_vinfo->vector_mode, false).require ();
> +
> + signed char partial_load_bias = internal_len_load_store_bias
> + (IFN_LEN_LOAD, len_load_mode);
> +
> + signed char partial_store_bias = internal_len_load_store_bias
> + (IFN_LEN_STORE, len_store_mode);
> +
> + gcc_assert (partial_load_bias == partial_store_bias);
> +
> + if (partial_load_bias == VECT_PARTIAL_BIAS_UNSUPPORTED)
> + return false;
> +
> + LOOP_VINFO_PARTIAL_LOAD_STORE_BIAS (loop_vinfo) = partial_load_bias;
> +
Nit, it seems better to move this assignment after the below early return.
> + /* If the backend requires a bias of -1 for LEN_LOAD, we must not emit
> + len_loads with a length of zero. In order to avoid that we prohibit
> + more than one loop length here. */
> + if (partial_load_bias == -1
> + && LOOP_VINFO_LENS (loop_vinfo).length () > 1)
> + return false;
> +
> unsigned int max_nitems_per_iter = 1;
> unsigned int i;
> rgroup_controls *rgl;
> @@ -4125,6 +4150,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
> here. */
>
> bool niters_known_p = LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo);
> + signed char partial_load_store_bias
> + = LOOP_VINFO_PARTIAL_LOAD_STORE_BIAS (loop_vinfo);
> bool need_iterate_p
> = (!LOOP_VINFO_EPILOGUE_P (loop_vinfo)
> && !vect_known_niters_smaller_than_vf (loop_vinfo));
> @@ -4157,6 +4184,11 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
> for each since start index is zero. */
> prologue_stmts += num_vectors;
>
> + /* If we have a non-zero partial load bias, we need one MINUS
> + and a MAX to adjust the load length. */
> + if (partial_load_store_bias != 0)
> + prologue_stmts += 2;
> +
IIUC, now we use the biasing length based on the PHI-ed loop_len, it has only one extra
unit cost for MINUS and it's part of cost for body instead of prologue?
> /* Each may need two MINs and one MINUS to update lengths in body
> for next iteration. */
> if (need_iterate_p)
> @@ -9226,6 +9258,13 @@ vect_get_loop_len (loop_vec_info loop_vinfo, vec_loop_lens *lens,
> {
> rgroup_controls *rgl = &(*lens)[nvectors - 1];
>
> + signed char partial_load_store_bias =
> + LOOP_VINFO_PARTIAL_LOAD_STORE_BIAS (loop_vinfo);
> +
> + bool use_bias_adjusted_len =
> + partial_load_store_bias != VECT_PARTIAL_BIAS_UNSUPPORTED
> + && partial_load_store_bias != 0;
> +
Nit, VECT_PARTIAL_BIAS_UNSUPPORTED check seems redundant here too.
BR,
Kewen
next prev parent reply other threads:[~2021-11-22 6:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-28 14:44 Robin Dapp
2021-10-29 3:10 ` Kewen.Lin
2021-10-29 7:46 ` Richard Sandiford
2021-11-02 20:16 ` Robin Dapp
2021-11-04 3:59 ` Kewen.Lin
2021-11-12 9:56 ` Robin Dapp
2021-11-22 6:55 ` Kewen.Lin [this message]
2021-12-07 11:52 ` Robin Dapp
2021-12-10 19:21 ` Richard Sandiford
2021-12-13 18:51 ` Robin Dapp
2021-12-14 11:47 ` Richard Sandiford
2022-01-10 12:53 ` Robin Dapp
2022-01-10 14:21 ` Richard Sandiford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3977d753-2bb4-3c47-22d2-b4948ddc38bd@linux.ibm.com \
--to=linkw@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rdapp@linux.ibm.com \
--cc=richard.sandiford@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).