From 1430fb1f563dd7434b262d1b1378d9954d13dc0c Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Wed, 27 Jan 2016 15:51:17 +0100 Subject: [PATCH] [PR 69355] Correct hole detection when total_scalarization fails 2016-01-27 Martin Jambor PR tree-optimization/69355 * tree-sra.c (analyze_access_subtree): Correct hole detection when total_scalarization fails. testsuite/ * gcc.dg/tree-ssa/pr69355.c: New test. From-SVN: r232877 --- gcc/ChangeLog | 6 ++++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/tree-ssa/pr69355.c | 44 +++++++++++++++++++++++++ gcc/tree-sra.c | 2 +- 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr69355.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2dbdd29ab293..824c69c1859f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-01-27 Martin Jambor + + PR tree-optimization/69355 + * tree-sra.c (analyze_access_subtree): Correct hole detection when + total_scalarization fails. + 2016-01-27 David Edelsohn * config/rs6000/driver-rs6000.c (detect_processor_aix): Add diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2ff4f7d40435..7dae86c1fe05 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-01-27 Martin Jambor + + PR tree-optimization/69355 + * gcc.dg/tree-ssa/pr69355.c: New test. + 2016-01-27 Marek Polacek PR c++/69496 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr69355.c b/gcc/testsuite/gcc.dg/tree-ssa/pr69355.c new file mode 100644 index 000000000000..f515c211c99b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr69355.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ +/* { dg-options "-O -fno-strict-aliasing" } */ + +struct S +{ + void *a; + long double b; +}; + +struct Z +{ + long long l; + short s; +} __attribute__((packed)); + +struct S __attribute__((noclone, noinline)) +foo (void *v, struct Z *z) +{ + struct S t; + t.a = v; + *(struct Z *) &t.b = *z; + return t; +} + +struct Z gz; + +int +main (int argc, char **argv) +{ + struct S s; + + if (sizeof (long double) < sizeof (struct Z)) + return 0; + + gz.l = 0xbeef; + gz.s = 0xab; + + s = foo ((void *) 0, &gz); + + if ((((struct Z *) &s.b)->l != gz.l) + || (((struct Z *) &s.b)->s != gz.s)) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 30a8244aa9e1..72157edd02e3 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2421,7 +2421,7 @@ analyze_access_subtree (struct access *root, struct access *parent, if (covered_to < limit) hole = true; - if (scalar) + if (scalar || !allow_replacements) root->grp_total_scalarization = 0; }