From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: [05/11] Add a vect_stmt_to_vectorize helper function
Date: Mon, 30 Jul 2018 11:39:00 -0000 [thread overview]
Message-ID: <87in4xdkbw.fsf@arm.com> (raw)
In-Reply-To: <874lghez1a.fsf@arm.com> (Richard Sandiford's message of "Mon, 30 Jul 2018 12:36:01 +0100")
This patch adds a helper that does the opposite of vect_orig_stmt:
go from the original scalar statement to the statement that should
actually be vectorised.
The use in the last two hunks of vectorizable_reduction are because
reduc_stmt_info (first hunk) and stmt_info (second hunk) are already
pattern statements if appropriate.
2018-07-30 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* tree-vectorizer.h (vect_stmt_to_vectorize): New function.
* tree-vect-loop.c (vect_update_vf_for_slp): Use it.
(vectorizable_reduction): Likewise.
* tree-vect-slp.c (vect_analyze_slp_instance): Likewise.
(vect_detect_hybrid_slp_stmts): Likewise.
* tree-vect-stmts.c (vect_is_simple_use): Likewise.
Index: gcc/tree-vectorizer.h
===================================================================
--- gcc/tree-vectorizer.h 2018-07-30 12:32:26.218536339 +0100
+++ gcc/tree-vectorizer.h 2018-07-30 12:32:29.586506669 +0100
@@ -1131,6 +1131,17 @@ vect_orig_stmt (stmt_vec_info stmt_info)
return stmt_info;
}
+/* If STMT_INFO has been replaced by a pattern statement, return the
+ replacement statement, otherwise return STMT_INFO itself. */
+
+inline stmt_vec_info
+vect_stmt_to_vectorize (stmt_vec_info stmt_info)
+{
+ if (STMT_VINFO_IN_PATTERN_P (stmt_info))
+ return STMT_VINFO_RELATED_STMT (stmt_info);
+ return stmt_info;
+}
+
/* Return true if BB is a loop header. */
static inline bool
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c 2018-07-30 12:32:26.214536374 +0100
+++ gcc/tree-vect-loop.c 2018-07-30 12:32:29.586506669 +0100
@@ -1424,9 +1424,7 @@ vect_update_vf_for_slp (loop_vec_info lo
gsi_next (&si))
{
stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (gsi_stmt (si));
- if (STMT_VINFO_IN_PATTERN_P (stmt_info)
- && STMT_VINFO_RELATED_STMT (stmt_info))
- stmt_info = STMT_VINFO_RELATED_STMT (stmt_info);
+ stmt_info = vect_stmt_to_vectorize (stmt_info);
if ((STMT_VINFO_RELEVANT_P (stmt_info)
|| VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info)))
&& !PURE_SLP_STMT (stmt_info))
@@ -6111,8 +6109,7 @@ vectorizable_reduction (stmt_vec_info st
return true;
stmt_vec_info reduc_stmt_info = STMT_VINFO_REDUC_DEF (stmt_info);
- if (STMT_VINFO_IN_PATTERN_P (reduc_stmt_info))
- reduc_stmt_info = STMT_VINFO_RELATED_STMT (reduc_stmt_info);
+ reduc_stmt_info = vect_stmt_to_vectorize (reduc_stmt_info);
if (STMT_VINFO_VEC_REDUCTION_TYPE (reduc_stmt_info)
== EXTRACT_LAST_REDUCTION)
@@ -6145,8 +6142,7 @@ vectorizable_reduction (stmt_vec_info st
if (ncopies > 1
&& STMT_VINFO_RELEVANT (reduc_stmt_info) <= vect_used_only_live
&& (use_stmt_info = loop_vinfo->lookup_single_use (phi_result))
- && (use_stmt_info == reduc_stmt_info
- || STMT_VINFO_RELATED_STMT (use_stmt_info) == reduc_stmt_info))
+ && vect_stmt_to_vectorize (use_stmt_info) == reduc_stmt_info)
single_defuse_cycle = true;
/* Create the destination vector */
@@ -6915,8 +6911,7 @@ vectorizable_reduction (stmt_vec_info st
if (ncopies > 1
&& (STMT_VINFO_RELEVANT (stmt_info) <= vect_used_only_live)
&& (use_stmt_info = loop_vinfo->lookup_single_use (reduc_phi_result))
- && (use_stmt_info == stmt_info
- || STMT_VINFO_RELATED_STMT (use_stmt_info) == stmt_info))
+ && vect_stmt_to_vectorize (use_stmt_info) == stmt_info)
{
single_defuse_cycle = true;
epilog_copies = 1;
Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c 2018-07-30 12:32:26.218536339 +0100
+++ gcc/tree-vect-slp.c 2018-07-30 12:32:29.586506669 +0100
@@ -1969,11 +1969,7 @@ vect_analyze_slp_instance (vec_info *vin
/* Collect the stores and store them in SLP_TREE_SCALAR_STMTS. */
while (next_info)
{
- if (STMT_VINFO_IN_PATTERN_P (next_info)
- && STMT_VINFO_RELATED_STMT (next_info))
- scalar_stmts.safe_push (STMT_VINFO_RELATED_STMT (next_info));
- else
- scalar_stmts.safe_push (next_info);
+ scalar_stmts.safe_push (vect_stmt_to_vectorize (next_info));
next_info = DR_GROUP_NEXT_ELEMENT (next_info);
}
}
@@ -1983,11 +1979,7 @@ vect_analyze_slp_instance (vec_info *vin
SLP_TREE_SCALAR_STMTS. */
while (next_info)
{
- if (STMT_VINFO_IN_PATTERN_P (next_info)
- && STMT_VINFO_RELATED_STMT (next_info))
- scalar_stmts.safe_push (STMT_VINFO_RELATED_STMT (next_info));
- else
- scalar_stmts.safe_push (next_info);
+ scalar_stmts.safe_push (vect_stmt_to_vectorize (next_info));
next_info = REDUC_GROUP_NEXT_ELEMENT (next_info);
}
/* Mark the first element of the reduction chain as reduction to properly
@@ -2325,9 +2317,7 @@ vect_detect_hybrid_slp_stmts (slp_tree n
use_vinfo = loop_vinfo->lookup_stmt (use_stmt);
if (!use_vinfo)
continue;
- if (STMT_VINFO_IN_PATTERN_P (use_vinfo)
- && STMT_VINFO_RELATED_STMT (use_vinfo))
- use_vinfo = STMT_VINFO_RELATED_STMT (use_vinfo);
+ use_vinfo = vect_stmt_to_vectorize (use_vinfo);
if (!STMT_SLP_TYPE (use_vinfo)
&& (STMT_VINFO_RELEVANT (use_vinfo)
|| VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (use_vinfo)))
Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c 2018-07-30 12:32:26.218536339 +0100
+++ gcc/tree-vect-stmts.c 2018-07-30 12:32:29.586506669 +0100
@@ -10031,11 +10031,8 @@ vect_is_simple_use (tree operand, vec_in
*dt = vect_external_def;
else
{
- if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo))
- {
- stmt_vinfo = STMT_VINFO_RELATED_STMT (stmt_vinfo);
- def_stmt = stmt_vinfo->stmt;
- }
+ stmt_vinfo = vect_stmt_to_vectorize (stmt_vinfo);
+ def_stmt = stmt_vinfo->stmt;
switch (gimple_code (def_stmt))
{
case GIMPLE_PHI:
next prev parent reply other threads:[~2018-07-30 11:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 11:36 [00/11] Add a vec_basic_block of scalar statements Richard Sandiford
2018-07-30 11:37 ` [02/11] Remove vect_schedule_slp return value Richard Sandiford
2018-08-01 12:49 ` Richard Biener
2018-07-30 11:37 ` [01/11] Schedule SLP earlier Richard Sandiford
2018-08-01 12:49 ` Richard Biener
2018-07-30 11:38 ` [04/11] Add a vect_orig_stmt helper function Richard Sandiford
2018-08-01 12:50 ` Richard Biener
2018-07-30 11:38 ` [03/11] Remove vect_transform_stmt grouped_store argument Richard Sandiford
2018-08-01 12:49 ` Richard Biener
2018-07-30 11:39 ` Richard Sandiford [this message]
2018-08-01 12:51 ` [05/11] Add a vect_stmt_to_vectorize helper function Richard Biener
2018-07-30 11:41 ` [06/11] Handle VMAT_INVARIANT separately Richard Sandiford
2018-08-01 12:52 ` Richard Biener
2018-07-30 11:42 ` [07/11] Use single basic block array in loop_vec_info Richard Sandiford
2018-08-01 12:58 ` Richard Biener
2018-07-30 11:43 ` [08/11] Make hoist_defs_of_uses use vec_info::lookup_def Richard Sandiford
2018-08-01 13:01 ` Richard Biener
2018-07-30 11:46 ` [10/11] Make the vectoriser do its own DCE Richard Sandiford
2018-07-30 11:46 ` [09/11] Add a vec_basic_block structure Richard Sandiford
2018-07-30 11:47 ` [11/11] Insert pattern statements into vec_basic_blocks 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=87in4xdkbw.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.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).