re PR tree-optimization/71908 (ICE at -Os and above in both 32-bit and 64-bit modes...
authorRichard Biener <rguenther@suse.de>
Tue, 19 Jul 2016 10:18:25 +0000 (10:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 19 Jul 2016 10:18:25 +0000 (10:18 +0000)
2016-07-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71908
* tree-ssa-structalias.c (get_constraint_for_component_ref): Handle
symbolic constants in a more reliable way.

* gcc.dg/torture/pr71908.c: New testcase.

From-SVN: r238467

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

index 43890647f3ba5f9b5a8272e01d95b3b8c4018721..1c57adc9543dcbd5c151ba2c5342bcb5060b1ab1 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71908
+       * tree-ssa-structalias.c (get_constraint_for_component_ref): Handle
+       symbolic constants in a more reliable way.
+
 2016-07-19  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        * tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer): Update
index 2dd59609bdd8abea74a3c4181d67b49c5a91b948..d0a3fcb37640bd98b5e62e2d0c03c3ee5d73bb6b 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71908
+       * gcc.dg/torture/pr71908.c: New testcase.
+
 2016-07-18  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/71493
diff --git a/gcc/testsuite/gcc.dg/torture/pr71908.c b/gcc/testsuite/gcc.dg/torture/pr71908.c
new file mode 100644 (file)
index 0000000..95d8748
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+
+struct S3
+{
+  int f3;
+  int f5;
+  char f6;
+  int f7;
+} b;
+int a;
+static struct S3 *c = &b;
+int *d;
+int main()
+{
+  int i;
+  for (;;) {
+      a = 0;
+      int **e = &d;
+      i = 0;
+      for (; i < 2; i++)
+       d = &(*c).f5;
+      *e = d;
+      **e = 3;
+  }
+  return 0;
+}
index 5e3c7d094b58a4296eae879a9c43a5b373a717ee..a96fcabf2701c04ebb74264ce6a7a007b16d7cfe 100644 (file)
@@ -3211,6 +3211,20 @@ get_constraint_for_component_ref (tree t, vec<ce_s> *results,
 
   t = get_ref_base_and_extent (t, &bitpos, &bitsize, &bitmaxsize, &reverse);
 
+  /* We can end up here for component references on a
+     VIEW_CONVERT_EXPR <>(&foobar) or things like a
+     BIT_FIELD_REF <&MEM[(void *)&b + 4B], ...>.  So for
+     symbolic constants simply give up.  */
+  if (TREE_CODE (t) == ADDR_EXPR)
+    {
+      constraint_expr result;
+      result.type = SCALAR;
+      result.var = anything_id;
+      result.offset = 0;
+      results->safe_push (result);
+      return;
+    }
+
   /* Pretend to take the address of the base, we'll take care of
      adding the required subset of sub-fields below.  */
   get_constraint_for_1 (t, results, true, lhs_p);
@@ -3300,8 +3314,8 @@ get_constraint_for_component_ref (tree t, vec<ce_s> *results,
     }
   else if (result.type == ADDRESSOF)
     {
-      /* We can end up here for component references on a
-         VIEW_CONVERT_EXPR <>(&foobar).  */
+      /* We can end up here for component references on constants like
+        VIEW_CONVERT_EXPR <>({ 0, 1, 2, 3 })[i].  */
       result.type = SCALAR;
       result.var = anything_id;
       result.offset = 0;