From dc3221e1e3d3a39d88d2d35103f6f50e3400d7a8 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 20 Nov 2018 09:31:06 +0000 Subject: [PATCH] re PR middle-end/83215 (C++: struct with char-array assumed to alias with everything) 2018-11-20 Richard Biener PR middle-end/83215 * alias.c (component_uses_parent_alias_set_from): Remove alias-set zero and TYPE_TYPELESS_STORAGE case both already handled in other ways. * g++.dg/tree-ssa/pr83215.C: New testcase. From-SVN: r266305 --- gcc/ChangeLog | 7 +++++++ gcc/alias.c | 10 +--------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/tree-ssa/pr83215.C | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr83215.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index affdfd6cdef..ee2d87d0313 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-11-20 Richard Biener + + PR middle-end/83215 + * alias.c (component_uses_parent_alias_set_from): Remove + alias-set zero and TYPE_TYPELESS_STORAGE case both already + handled in other ways. + 2018-11-20 Richard Biener PR tree-optimization/88087 diff --git a/gcc/alias.c b/gcc/alias.c index 7963ece291a..835ac82ae82 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -601,8 +601,7 @@ objects_must_conflict_p (tree t1, tree t2) /* Return the outermost parent of component present in the chain of component references handled by get_inner_reference in T with the following property: - - the component is non-addressable, or - - the parent has alias set zero, + - the component is non-addressable or NULL_TREE if no such parent exists. In the former cases, the alias set of this parent is the alias set that must be used for T itself. */ @@ -611,10 +610,6 @@ component_uses_parent_alias_set_from (const_tree t) { const_tree found = NULL_TREE; - if (AGGREGATE_TYPE_P (TREE_TYPE (t)) - && TYPE_TYPELESS_STORAGE (TREE_TYPE (t))) - return const_cast (t); - while (handled_component_p (t)) { switch (TREE_CODE (t)) @@ -652,9 +647,6 @@ component_uses_parent_alias_set_from (const_tree t) gcc_unreachable (); } - if (get_alias_set (TREE_TYPE (TREE_OPERAND (t, 0))) == 0) - found = t; - t = TREE_OPERAND (t, 0); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e3780472a3d..31540b58266 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-11-20 Richard Biener + + PR middle-end/83215 + * g++.dg/tree-ssa/pr83215.C: New testcase. + 2018-11-20 Eric Botcazou * gcc.c-torture/execute/20181120-1.c: New test. diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr83215.C b/gcc/testsuite/g++.dg/tree-ssa/pr83215.C new file mode 100644 index 00000000000..d21ac46b28b --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr83215.C @@ -0,0 +1,19 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-fre1" } + +struct mytest +{ + float a; + char buf[256]; +}; + +int foo(mytest *m, int *i) +{ + int tmp = *i; + m->a = 10.0f; + return tmp + *i; +} + +// we should be able to CSE *i despite mytest having a cbar[] buffer +// and thus being subject to TYPE_TYPELESS_STORAGE +// { dg-final { scan-tree-dump-times "\\*i" 1 "fre1" } } -- 2.30.2