From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR81790
Date: Tue, 15 Aug 2017 09:28:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.20.1708150858120.14191@zhemvz.fhfr.qr> (raw)
This PR uncovers a missed-optimization with looking up CONSTRUCTORs
resulting from match-and-simplify simplification. Those appear in
"GENERIC" form while VN internally uses exploded form.
Thus make vn_lookup_simplify_result mediate between the two -- with
the additional complication of vn_nary_simplify getting here
(eventually) with non-simplified exploded form already.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2017-08-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/81790
* tree-ssa-sccvn.c (vn_lookup_simplify_result): Handle both
CONSTRUCTORs from simplifying and VN.
* gcc.dg/torture/pr81790.c: New testcase.
Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c (revision 251086)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -1646,13 +1646,25 @@ static unsigned mprts_hook_cnt;
/* Hook for maybe_push_res_to_seq, lookup the expression in the VN tables. */
static tree
-vn_lookup_simplify_result (code_helper rcode, tree type, tree *ops)
+vn_lookup_simplify_result (code_helper rcode, tree type, tree *ops_)
{
if (!rcode.is_tree_code ())
return NULL_TREE;
+ tree *ops = ops_;
+ unsigned int length = TREE_CODE_LENGTH ((tree_code) rcode);
+ if (rcode == CONSTRUCTOR
+ /* ??? We're arriving here with SCCVNs view, decomposed CONSTRUCTOR
+ and GIMPLEs / match-and-simplifies, CONSTRUCTOR as GENERIC tree. */
+ && TREE_CODE (ops_[0]) == CONSTRUCTOR)
+ {
+ length = CONSTRUCTOR_NELTS (ops_[0]);
+ ops = XALLOCAVEC (tree, length);
+ for (unsigned i = 0; i < length; ++i)
+ ops[i] = CONSTRUCTOR_ELT (ops_[0], i)->value;
+ }
vn_nary_op_t vnresult = NULL;
- tree res = vn_nary_op_lookup_pieces (TREE_CODE_LENGTH ((tree_code) rcode),
- (tree_code) rcode, type, ops, &vnresult);
+ tree res = vn_nary_op_lookup_pieces (length, (tree_code) rcode,
+ type, ops, &vnresult);
/* We can end up endlessly recursing simplifications if the lookup above
presents us with a def-use chain that mirrors the original simplification.
See PR80887 for an example. Limit successful lookup artificially
Index: gcc/testsuite/gcc.dg/torture/pr81790.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr81790.c (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr81790.c (working copy)
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-additional-options "--param sccvn-max-scc-size=10" } */
+
+typedef int a __attribute__ ((__vector_size__ (16)));
+typedef struct
+{
+ a b;
+} c;
+
+int d, e;
+
+void foo (c *ptr);
+
+void bar ()
+{
+ double b = 1842.9028;
+ c g, h;
+ if (d)
+ b = 77.7998;
+ for (; e;)
+ {
+ g.b = g.b = g.b + g.b;
+ h.b = (a){b};
+ h.b = h.b + h.b;
+ }
+ foo (&g);
+ foo (&h);
+}
reply other threads:[~2017-08-15 7:01 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=alpine.LSU.2.20.1708150858120.14191@zhemvz.fhfr.qr \
--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).