From 420ee75d7dbdba35878d7feabea7d30d77b82943 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 2 May 2019 14:05:27 +0000 Subject: [PATCH] re PR tree-optimization/89509 (restrict doesnt work with subfield accesses) 2019-05-02 Richard Biener 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. From-SVN: r270799 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/restrict-8.c | 17 +++++++++++++++++ gcc/tree-ssa-structalias.c | 5 ++++- 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/restrict-8.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1f55cd18210..f4f0c14ca25 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-05-02 Richard Biener + + PR tree-optimization/89509 + * tree-ssa-structalias.c (compute_dependence_clique): Look + at the first subvar when determining whether it is restrict. + 2019-05-02 Richard Biener PR tree-optimization/90273 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 40228949942..3976e36ad4b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-05-02 Richard Biener + + PR tree-optimization/89509 + * gcc.dg/torture/restrict-8.c: New testcase. + 2019-05-02 Iain Sandoe * gcc.dg/tree-prof/section-attr-1.c: Update scan-asm regex diff --git a/gcc/testsuite/gcc.dg/torture/restrict-8.c b/gcc/testsuite/gcc.dg/torture/restrict-8.c new file mode 100644 index 00000000000..0118de0133c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/restrict-8.c @@ -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" } } */ diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 4a0b02e9b03..2e2b0e8cb1e 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -7588,9 +7588,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)) { -- 2.30.2