From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 1/4] Avoid requiring VEC_PERM represenatives
Date: Tue, 21 May 2024 14:44:34 +0200 (CEST) [thread overview]
Message-ID: <20240521124438.CDADB13A21@imap1.dmz-prg2.suse.org> (raw)
The following plugs one hole where we require a VEC_PERM node
representative unnecessarily. This is for vect_check_store_rhs
which looks at the RHS and checks whether a constant can be
native encoded. The fix is to guard that with vect_constant_def
additionally and making vect_is_simple_use forgiving for a missing
SLP_TREE_REPRESENTATIVE when the child is a VEC_PERM node,
initializing the scalar def to error_mark_node.
* tree-vect-stmts.cc (vect_check_store_rhs): Look at *rhs
only when it's a vec_constant_def.
(vect_is_simple_use): When we have no representative for
an internal node, fill in *op with error_mark_node.
---
gcc/tree-vect-stmts.cc | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 672959501bb..4219ad832db 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -2553,7 +2553,8 @@ vect_check_store_rhs (vec_info *vinfo, stmt_vec_info stmt_info,
/* In the case this is a store from a constant make sure
native_encode_expr can handle it. */
- if (CONSTANT_CLASS_P (*rhs) && native_encode_expr (*rhs, NULL, 64) == 0)
+ if (rhs_dt == vect_constant_def
+ && CONSTANT_CLASS_P (*rhs) && native_encode_expr (*rhs, NULL, 64) == 0)
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -14002,8 +14003,26 @@ vect_is_simple_use (vec_info *vinfo, stmt_vec_info stmt, slp_tree slp_node,
*vectype = SLP_TREE_VECTYPE (child);
if (SLP_TREE_DEF_TYPE (child) == vect_internal_def)
{
- *op = gimple_get_lhs (SLP_TREE_REPRESENTATIVE (child)->stmt);
- return vect_is_simple_use (*op, vinfo, dt, def_stmt_info_out);
+ /* ??? VEC_PERM nodes might be intermediate and their lane value
+ have no representative (nor do we build a VEC_PERM stmt for
+ the actual operation). Note for two-operator nodes we set
+ a representative but leave scalar stmts empty as we'd only
+ have one for a subset of lanes. Ideally no caller would
+ require *op for internal defs. */
+ if (SLP_TREE_REPRESENTATIVE (child))
+ {
+ *op = gimple_get_lhs (SLP_TREE_REPRESENTATIVE (child)->stmt);
+ return vect_is_simple_use (*op, vinfo, dt, def_stmt_info_out);
+ }
+ else
+ {
+ gcc_assert (SLP_TREE_CODE (child) == VEC_PERM_EXPR);
+ *op = error_mark_node;
+ *dt = vect_internal_def;
+ if (def_stmt_info_out)
+ *def_stmt_info_out = NULL;
+ return true;
+ }
}
else
{
--
2.35.3
reply other threads:[~2024-05-21 12:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240521124438.CDADB13A21@imap1.dmz-prg2.suse.org \
--to=rguenther@suse.de \
--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).