From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: richard.sandiford@arm.com
Subject: [PATCH 1/2] Streamline vect_gen_while
Date: Thu, 15 Jul 2021 12:27:57 +0200 (CEST) [thread overview]
Message-ID: <3q748918-s965-rs18-s3qp-27p7r45o9o@fhfr.qr> (raw)
This adjusts the vect_gen_while API to match that of
vect_gen_while_not allowing further patches to generate more
than one stmt for the while case.
Bootstrapped and tested on x86_64-unknown-linux-gnu, tested a
toy example on SVE that it still produces the same code.
OK?
2021-07-15 Richard Biener <rguenther@suse.de>
* tree-vectorizer.h (vect_gen_while): Match up with
vect_gen_while_not.
* tree-vect-stmts.c (vect_gen_while): Adjust API to that
of vect_gen_while_not.
(vect_gen_while_not): Adjust.
* tree-vect-loop-manip.c (vect_set_loop_controls_directly): Likewise.
---
gcc/tree-vect-loop-manip.c | 14 ++++++--------
gcc/tree-vect-stmts.c | 16 ++++++++--------
gcc/tree-vectorizer.h | 3 ++-
3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index c29ffb3356c..1f3d6614e6c 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -609,11 +609,8 @@ vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
}
if (use_masks_p)
- {
- init_ctrl = make_temp_ssa_name (ctrl_type, NULL, "max_mask");
- gimple *tmp_stmt = vect_gen_while (init_ctrl, start, end);
- gimple_seq_add_stmt (preheader_seq, tmp_stmt);
- }
+ init_ctrl = vect_gen_while (preheader_seq, ctrl_type,
+ start, end, "max_mask");
else
{
init_ctrl = make_temp_ssa_name (compare_type, NULL, "max_len");
@@ -652,9 +649,10 @@ vect_set_loop_controls_directly (class loop *loop, loop_vec_info loop_vinfo,
/* Get the control value for the next iteration of the loop. */
if (use_masks_p)
{
- next_ctrl = make_temp_ssa_name (ctrl_type, NULL, "next_mask");
- gcall *call = vect_gen_while (next_ctrl, test_index, this_test_limit);
- gsi_insert_before (test_gsi, call, GSI_SAME_STMT);
+ gimple_seq stmts = NULL;
+ next_ctrl = vect_gen_while (&stmts, ctrl_type, test_index,
+ this_test_limit, "next_mask");
+ gsi_insert_seq_before (test_gsi, stmts, GSI_SAME_STMT);
}
else
{
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index d9eeda50278..6a25d661800 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -12002,19 +12002,21 @@ supportable_narrowing_operation (enum tree_code code,
/* Generate and return a statement that sets vector mask MASK such that
MASK[I] is true iff J + START_INDEX < END_INDEX for all J <= I. */
-gcall *
-vect_gen_while (tree mask, tree start_index, tree end_index)
+tree
+vect_gen_while (gimple_seq *seq, tree mask_type, tree start_index,
+ tree end_index, const char *name)
{
tree cmp_type = TREE_TYPE (start_index);
- tree mask_type = TREE_TYPE (mask);
gcc_checking_assert (direct_internal_fn_supported_p (IFN_WHILE_ULT,
cmp_type, mask_type,
OPTIMIZE_FOR_SPEED));
gcall *call = gimple_build_call_internal (IFN_WHILE_ULT, 3,
start_index, end_index,
build_zero_cst (mask_type));
- gimple_call_set_lhs (call, mask);
- return call;
+ tree tmp = make_temp_ssa_name (mask_type, NULL, name);
+ gimple_call_set_lhs (call, tmp);
+ gimple_seq_add_stmt (seq, call);
+ return tmp;
}
/* Generate a vector mask of type MASK_TYPE for which index I is false iff
@@ -12024,9 +12026,7 @@ tree
vect_gen_while_not (gimple_seq *seq, tree mask_type, tree start_index,
tree end_index)
{
- tree tmp = make_ssa_name (mask_type);
- gcall *call = vect_gen_while (tmp, start_index, end_index);
- gimple_seq_add_stmt (seq, call);
+ tree tmp = vect_gen_while (seq, mask_type, start_index, end_index);
return gimple_build (seq, BIT_NOT_EXPR, mask_type, tmp);
}
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 4c4bc810c35..49afdd898d0 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -1948,7 +1948,8 @@ extern bool vect_supportable_shift (vec_info *, enum tree_code, tree);
extern tree vect_gen_perm_mask_any (tree, const vec_perm_indices &);
extern tree vect_gen_perm_mask_checked (tree, const vec_perm_indices &);
extern void optimize_mask_stores (class loop*);
-extern gcall *vect_gen_while (tree, tree, tree);
+extern tree vect_gen_while (gimple_seq *, tree, tree, tree,
+ const char * = nullptr);
extern tree vect_gen_while_not (gimple_seq *, tree, tree, tree);
extern opt_result vect_get_vector_types_for_stmt (vec_info *,
stmt_vec_info, tree *,
--
2.26.2
next reply other threads:[~2021-07-15 10:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-15 10:27 Richard Biener [this message]
2021-07-15 12:48 ` 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=3q748918-s965-rs18-s3qp-27p7r45o9o@fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--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).