From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/107935 - fixup equivalence handling in PHI VN
Date: Thu, 1 Dec 2022 10:18:22 +0100 (CET) [thread overview]
Message-ID: <20221201091823.3D45F13B4A@imap2.suse-dmz.suse.de> (raw)
The following makes sure to honor the backedge processing logic
that forces VARYING there.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/107935
* tree-ssa-sccvn.cc (visit_phi): Honor forced VARYING on
backedges.
* gcc.dg/torture/pr107935.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr107935.c | 18 ++++++++++++++++++
gcc/tree-ssa-sccvn.cc | 7 ++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr107935.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr107935.c b/gcc/testsuite/gcc.dg/torture/pr107935.c
new file mode 100644
index 00000000000..78175100f80
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr107935.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+int *a, **b;
+int main() {
+ int d = 0, *e = &d;
+ L:
+ *e = d;
+ if (a) {
+ int *g = e = *b;
+ if (!e)
+ __builtin_abort();
+ if (**b)
+ return 0;
+ *g = 1;
+ goto L;
+ }
+ return 0;
+}
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 6895ae84d13..fa2f65df159 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -5861,7 +5861,12 @@ visit_phi (gimple *phi, bool *inserted, bool backedges_varying_p)
continue;
}
/* There's also the possibility to use equivalences. */
- if (!FLOAT_TYPE_P (TREE_TYPE (def)))
+ if (!FLOAT_TYPE_P (TREE_TYPE (def))
+ /* But only do this if we didn't force any of sameval or
+ val to VARYING because of backedge processing rules. */
+ && (TREE_CODE (sameval) != SSA_NAME
+ || SSA_VAL (sameval) == sameval)
+ && (TREE_CODE (def) != SSA_NAME || SSA_VAL (def) == def))
{
vn_nary_op_t vnresult;
tree ops[2];
--
2.35.3
reply other threads:[~2022-12-01 9:18 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=20221201091823.3D45F13B4A@imap2.suse-dmz.suse.de \
--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).