From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/110204 - second level redundancy and simplification
Date: Thu, 20 Jul 2023 12:45:52 +0000 (UTC) [thread overview]
Message-ID: <20230720124552.9mMWnMjzbH_gcF6xCZJld-T1iI94eSMXIgYCpG92Qss@z> (raw)
When PRE discovers a full redundancy during insertion it cannot unite
the two value sets. Instead it inserts a copy old-val = new-val where
new-val can also be a constant. The following looks through such
copies during elimination, providing one extra level of constant and
copy propagation. For the PR this helps avoiding a bogus diagnostic
that's emitted on unreachable code during loop optimization.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
Richard.
PR tree-optimization/110204
* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_avail):
Look through copies generated by PRE.
---
gcc/tree-ssa-sccvn.cc | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 11061a374a2..a0b98c18ac8 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -6594,7 +6594,22 @@ eliminate_dom_walker::eliminate_avail (basic_block, tree op)
if (SSA_NAME_IS_DEFAULT_DEF (valnum))
return valnum;
if (avail.length () > SSA_NAME_VERSION (valnum))
- return avail[SSA_NAME_VERSION (valnum)];
+ {
+ tree av = avail[SSA_NAME_VERSION (valnum)];
+ /* When PRE discovers a new redundancy there's no way to unite
+ the value classes so it instead inserts a copy old-val = new-val.
+ Look through such copies here, providing one more level of
+ simplification at elimination time. */
+ gassign *ass;
+ if (av && (ass = dyn_cast <gassign *> (SSA_NAME_DEF_STMT (av))))
+ if (gimple_assign_rhs_class (ass) == GIMPLE_SINGLE_RHS)
+ {
+ tree rhs1 = gimple_assign_rhs1 (ass);
+ if (CONSTANT_CLASS_P (rhs1) || TREE_CODE (rhs1) == SSA_NAME)
+ av = rhs1;
+ }
+ return av;
+ }
}
else if (is_gimple_min_invariant (valnum))
return valnum;
--
2.35.3
reply other threads:[~2023-07-20 12:45 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=20230720124552.9mMWnMjzbH_gcF6xCZJld-T1iI94eSMXIgYCpG92Qss@z \
--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).