The following fixes PR71908.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2016-07-18  Richard Biener  <rguent...@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.

Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c  (revision 238426)
--- gcc/tree-ssa-structalias.c  (working copy)
*************** get_constraint_for_component_ref (tree t
*** 3211,3216 ****
--- 3211,3230 ----
  
    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);
*************** get_constraint_for_component_ref (tree t
*** 3298,3311 ****
        else
        result.offset += bitpos;
      }
-   else if (result.type == ADDRESSOF)
-     {
-       /* We can end up here for component references on a
-          VIEW_CONVERT_EXPR <>(&foobar).  */
-       result.type = SCALAR;
-       result.var = anything_id;
-       result.offset = 0;
-     }
    else
      gcc_unreachable ();
  }
--- 3312,3317 ----
Index: gcc/testsuite/gcc.dg/torture/pr71908.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr71908.c      (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr71908.c      (working copy)
***************
*** 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;
+ }

Reply via email to