The following fixes PR89509.
Bootstrapped / tested on x86_64-unknown-linux-gnu, applied. Richard. 2019-05-02 Richard Biener <rguent...@suse.de> PR tree-optimization/89509 * tree-ssa-structalias.c (compute_dependence_clique): Look at the first subvar when determining whether it is restrict. * gcc.dg/torture/restrict-8.c: New testcase. Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 269212) +++ gcc/tree-ssa-structalias.c (working copy) @@ -7572,9 +7572,12 @@ compute_dependence_clique (void) EXECUTE_IF_SET_IN_BITMAP (vi->solution, 0, j, bi) { varinfo_t oi = get_varinfo (j); + if (oi->head != j) + oi = get_varinfo (oi->head); if (oi->is_restrict_var) { - if (restrict_var) + if (restrict_var + && restrict_var != oi) { if (dump_file && (dump_flags & TDF_DETAILS)) { Index: gcc/testsuite/gcc.dg/torture/restrict-8.c =================================================================== --- gcc/testsuite/gcc.dg/torture/restrict-8.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/restrict-8.c (working copy) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ +/* { dg-options "-fdump-tree-fre1" } */ + +struct S { int i; void *p; int j; }; +int +foo (struct S * __restrict p, int *q, int flag) +{ + int *x = &p->j; + if (flag) + x = &p->i; + *q = 1; + *x = 2; + return *q; +} + +/* { dg-final { scan-tree-dump "return 1;" "fre1" } } */