From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>, Jeff Law <jeffreyalaw@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-vect-generic: Fix up ICE with SSA_NAME_OCCURS_IN_ABNORMAL_PHI [PR109392]
Date: Wed, 5 Apr 2023 10:58:08 +0200 [thread overview]
Message-ID: <ZC04IGSaDzQarXvq@tucnak> (raw)
Hi!
tree_vect_extract uses gimple-fold/match.pd to attempt to simplify
the BIT_FIELD_REF immediately.
Unfortunately, maybe_push_res_to_seq has:
/* Play safe and do not allow abnormals to be mentioned in
newly created statements. */
for (unsigned int i = 0; i < num_ops; ++i)
if (TREE_CODE (ops[i]) == SSA_NAME
&& SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[i]))
return NULL_TREE;
if (num_ops > 0 && COMPARISON_CLASS_P (ops[0]))
for (unsigned int i = 0; i < 2; ++i)
if (TREE_CODE (TREE_OPERAND (ops[0], i)) == SSA_NAME
&& SSA_NAME_OCCURS_IN_ABNORMAL_PHI (TREE_OPERAND (ops[0], i)))
return NULL_TREE;
and so can fail in presence of SSA_NAME_OCCURS_IN_ABNORMAL_PHI SSA_NAMEs,
where we then trigger the assert that maybe_push_res_to_seq doesn't return
NULL. The above is perfectly reasonable when trying to actually simplify
something that has been already created and let us just punt, but in the
tree_vect_extract case we have to build something always.
The following patch fixes it by building the BIT_FIELD_REF manually in
that case if the build+simplification failed.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2023-04-05 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/109392
* tree-vect-generic.cc (tree_vec_extract): If maybe_push_res_to_seq
fails, build BIT_FIELD_REF insn without trying to simplify it.
* gcc.dg/pr109392.c: New test.
--- gcc/tree-vect-generic.cc.jj 2023-03-23 10:02:18.997935620 +0100
+++ gcc/tree-vect-generic.cc 2023-04-04 14:28:32.977729134 +0200
@@ -174,7 +174,16 @@ tree_vec_extract (gimple_stmt_iterator *
opr.resimplify (NULL, follow_all_ssa_edges);
gimple_seq stmts = NULL;
tree res = maybe_push_res_to_seq (&opr, &stmts);
- gcc_assert (res);
+ if (!res)
+ {
+ /* This can happen if SSA_NAME_OCCURS_IN_ABNORMAL_PHI are
+ used. Build BIT_FIELD_REF manually otherwise. */
+ t = build3 (BIT_FIELD_REF, type, t, bitsize, bitpos);
+ res = make_ssa_name (type);
+ gimple *g = gimple_build_assign (res, t);
+ gsi_insert_before (gsi, g, GSI_SAME_STMT);
+ return res;
+ }
gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
return res;
}
--- gcc/testsuite/gcc.dg/pr109392.c.jj 2023-04-04 14:36:03.096109943 +0200
+++ gcc/testsuite/gcc.dg/pr109392.c 2023-04-04 14:35:39.784452751 +0200
@@ -0,0 +1,15 @@
+/* PR tree-optimization/109392 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-psabi" } */
+
+typedef short __attribute__ ((__vector_size__ (64))) V;
+V v, w;
+void bar (void) __attribute__((returns_twice));
+
+V
+foo (V a, V b)
+{
+ bar ();
+ b &= v < b;
+ return (V) { foo (b, w)[3], (V) {}[3] };
+}
Jakub
next reply other threads:[~2023-04-05 8:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 8:58 Jakub Jelinek [this message]
2023-04-05 12:11 ` Richard Biener
2023-04-11 8:04 ` Jakub Jelinek
2023-04-11 10:38 ` 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=ZC04IGSaDzQarXvq@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=rguenther@suse.de \
/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).