re PR tree-optimization/81790 (ICE in vn_nary_build_or_lookup_1, at tree-ssa-sccvn...
authorRichard Biener <rguenther@suse.de>
Tue, 15 Aug 2017 11:26:32 +0000 (11:26 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 15 Aug 2017 11:26:32 +0000 (11:26 +0000)
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.

From-SVN: r251103

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr81790.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index 2cd7917164ffcc7e4cd24f1c0c47368db0b713cc..d899430111640f1c763a4c641de14f891d333682 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2017-08-14  Martin Sebor  <msebor@redhat.com>
 
        * builtin-attrs.def: Add comments.
index ddbafae0fe3a54dd9572e741af23039b6af6088f..f13f9b05003343d5fb24b9d5f326eeb19a6ce308 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-15  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/81790
+       * gcc.dg/torture/pr81790.c: New testcase.
+
 2017-08-14  Martin Sebor  <msebor@redhat.com>
 
        PR c/81117
diff --git a/gcc/testsuite/gcc.dg/torture/pr81790.c b/gcc/testsuite/gcc.dg/torture/pr81790.c
new file mode 100644 (file)
index 0000000..b5e02f6
--- /dev/null
@@ -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);
+}
index d62a49d2d1e55ce7219a2a0c8c595f3d38574158..19db44a3d4c52fcb011505ac8b70f49a12b9ef5c 100644 (file)
@@ -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