From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com,
segher@kernel.crashing.org, bergner@linux.ibm.com
Subject: [PATCH 2/9 v2] vect: Adjust vectorizable_load costing on VMAT_GATHER_SCATTER && gs_info.decl
Date: Mon, 3 Jul 2023 10:57:58 +0800 [thread overview]
Message-ID: <90665240-729b-b07e-61a9-eed0cbdff95a@linux.ibm.com> (raw)
In-Reply-To: <CAFiYyc1d9=q83joE9D_6Zmju-gHqUpxJ79HLkYQeJd2f9zu6XA@mail.gmail.com>
Hi Richi,
on 2023/6/30 19:11, Richard Biener wrote:
> On Tue, Jun 13, 2023 at 4:03 AM Kewen Lin <linkw@linux.ibm.com> wrote:
>>
>> This patch adds one extra argument cost_vec to function
>> vect_build_gather_load_calls, so that we can do costing
>> next to the tranform in vect_build_gather_load_calls.
>> For now, the implementation just follows the handlings in
>> vect_model_load_cost, it isn't so good, so placing one
>> FIXME for any further improvement. This patch should not
>> cause any functional changes.
>>
>> gcc/ChangeLog:
>>
>> * tree-vect-stmts.cc (vect_build_gather_load_calls): Add the handlings
>> on costing with one extra argument cost_vec.
>> (vectorizable_load): Adjust the call to vect_build_gather_load_calls.
>> (vect_model_load_cost): Assert it won't get VMAT_GATHER_SCATTER with
>> gs_info.decl set any more.
>> ---
>> gcc/tree-vect-stmts.cc | 31 +++++++++++++++++++++++--------
>> 1 file changed, 23 insertions(+), 8 deletions(-)
>>
>> diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
>> index 44514658be3..744cdf40e26 100644
>> --- a/gcc/tree-vect-stmts.cc
>> +++ b/gcc/tree-vect-stmts.cc
>> @@ -1135,6 +1135,8 @@ vect_model_load_cost (vec_info *vinfo,
>> slp_tree slp_node,
>> stmt_vector_for_cost *cost_vec)
>> {
>> + gcc_assert (memory_access_type != VMAT_GATHER_SCATTER || !gs_info->decl);
>> +
>> unsigned int inside_cost = 0, prologue_cost = 0;
>> bool grouped_access_p = STMT_VINFO_GROUPED_ACCESS (stmt_info);
>>
>> @@ -2819,7 +2821,8 @@ vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info,
>> gimple_stmt_iterator *gsi,
>> gimple **vec_stmt,
>> gather_scatter_info *gs_info,
>> - tree mask)
>> + tree mask,
>> + stmt_vector_for_cost *cost_vec)
>> {
>> loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo);
>> class loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
>> @@ -2831,6 +2834,23 @@ vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info,
>> poly_uint64 gather_off_nunits
>> = TYPE_VECTOR_SUBPARTS (gs_info->offset_vectype);
>>
>> + /* FIXME: Keep the previous costing way in vect_model_load_cost by costing
>> + N scalar loads, but it should be tweaked to use target specific costs
>> + on related gather load calls. */
>> + if (!vec_stmt)
>
> going over the series now, I'm collecting comments but wanted to get
> this one out here:
> I'd rather see if (cost_vec) here, that 'vec_stmt' argument is quite
> legacy (I think it can
> be completely purged everywhere)
>
OK, updated with the below new version v2. I guessed you meant we would like to
use cost_vec for checking costing or not and use vec_stmts in stmt_info to store
the vectorized stmt.
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index ec177dcad82..dd8f5421d4e 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -1136,6 +1136,8 @@ vect_model_load_cost (vec_info *vinfo,
slp_tree slp_node,
stmt_vector_for_cost *cost_vec)
{
+ gcc_assert (memory_access_type != VMAT_GATHER_SCATTER || !gs_info->decl);
+
unsigned int inside_cost = 0, prologue_cost = 0;
bool grouped_access_p = STMT_VINFO_GROUPED_ACCESS (stmt_info);
@@ -2846,7 +2848,8 @@ vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info,
gimple_stmt_iterator *gsi,
gimple **vec_stmt,
gather_scatter_info *gs_info,
- tree mask)
+ tree mask,
+ stmt_vector_for_cost *cost_vec)
{
loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo);
class loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
@@ -2858,6 +2861,23 @@ vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info,
poly_uint64 gather_off_nunits
= TYPE_VECTOR_SUBPARTS (gs_info->offset_vectype);
+ /* FIXME: Keep the previous costing way in vect_model_load_cost by costing
+ N scalar loads, but it should be tweaked to use target specific costs
+ on related gather load calls. */
+ if (cost_vec)
+ {
+ unsigned int assumed_nunits = vect_nunits_for_cost (vectype);
+ unsigned int inside_cost;
+ inside_cost = record_stmt_cost (cost_vec, ncopies * assumed_nunits,
+ scalar_load, stmt_info, 0, vect_body);
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "vect_model_load_cost: inside_cost = %d, "
+ "prologue_cost = 0 .\n",
+ inside_cost);
+ return;
+ }
+
tree arglist = TYPE_ARG_TYPES (TREE_TYPE (gs_info->decl));
tree rettype = TREE_TYPE (TREE_TYPE (gs_info->decl));
tree srctype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist);
@@ -9631,13 +9651,8 @@ vectorizable_load (vec_info *vinfo,
if (memory_access_type == VMAT_GATHER_SCATTER && gs_info.decl)
{
- if (costing_p)
- vect_model_load_cost (vinfo, stmt_info, ncopies, vf, memory_access_type,
- alignment_support_scheme, misalignment, &gs_info,
- slp_node, cost_vec);
- else
- vect_build_gather_load_calls (vinfo, stmt_info, gsi, vec_stmt, &gs_info,
- mask);
+ vect_build_gather_load_calls (vinfo, stmt_info, gsi, vec_stmt, &gs_info,
+ mask, cost_vec);
return true;
}
--
2.31.1
next prev parent reply other threads:[~2023-07-03 2:58 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 2:03 [PATCH 0/9] vect: Move costing next to the transform for vect load Kewen Lin
2023-06-13 2:03 ` [PATCH 1/9] vect: Move vect_model_load_cost next to the transform in vectorizable_load Kewen Lin
2023-06-13 2:03 ` [PATCH 2/9] vect: Adjust vectorizable_load costing on VMAT_GATHER_SCATTER && gs_info.decl Kewen Lin
2023-06-30 11:11 ` Richard Biener
2023-07-03 2:57 ` Kewen.Lin [this message]
2023-06-13 2:03 ` [PATCH 3/9] vect: Adjust vectorizable_load costing on VMAT_INVARIANT Kewen Lin
2023-06-30 11:18 ` Richard Biener
2023-07-03 2:58 ` [PATCH 3/9 v2] " Kewen.Lin
2023-06-13 2:03 ` [PATCH 4/9] vect: Adjust vectorizable_load costing on VMAT_ELEMENTWISE and VMAT_STRIDED_SLP Kewen Lin
2023-07-02 8:58 ` Richard Sandiford
2023-07-03 3:19 ` Kewen.Lin
2023-07-22 15:58 ` Iain Sandoe
2023-07-24 1:50 ` Kewen.Lin
2023-06-13 2:03 ` [PATCH 5/9] vect: Adjust vectorizable_load costing on VMAT_GATHER_SCATTER Kewen Lin
2023-07-03 3:01 ` [PATCH 5/9 v2] " Kewen.Lin
2023-06-13 2:03 ` [PATCH 6/9] vect: Adjust vectorizable_load costing on VMAT_LOAD_STORE_LANES Kewen Lin
2023-06-13 2:03 ` [PATCH 7/9] vect: Adjust vectorizable_load costing on VMAT_CONTIGUOUS_REVERSE Kewen Lin
2023-06-13 2:03 ` [PATCH 8/9] vect: Adjust vectorizable_load costing on VMAT_CONTIGUOUS_PERMUTE Kewen Lin
2023-06-14 8:17 ` Hongtao Liu
2023-06-19 7:23 ` Kewen.Lin
2023-06-13 2:03 ` [PATCH 9/9] vect: Adjust vectorizable_load costing on VMAT_CONTIGUOUS Kewen Lin
2023-07-03 3:06 ` [PATCH 9/9 v2] " Kewen.Lin
2023-06-26 6:00 ` [PATCH 0/9] vect: Move costing next to the transform for vect load Kewen.Lin
2023-06-30 11:37 ` Richard Biener
2023-07-02 9:13 ` Richard Sandiford
2023-07-03 3:39 ` Kewen.Lin
2023-07-03 8:42 ` Richard Biener
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=90665240-729b-b07e-61a9-eed0cbdff95a@linux.ibm.com \
--to=linkw@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
--cc=richard.sandiford@arm.com \
--cc=segher@kernel.crashing.org \
/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).