diff options
author | Jan Hubicka <jh@suse.cz> | 2019-06-22 17:32:51 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2019-06-22 15:32:51 +0000 |
commit | 1240df7b4075f043a00c5314318f3bbf9af719e6 (patch) | |
tree | afc8d42d6f812236b8cd6de35319555455c70d83 /gcc | |
parent | 78f7607db4c53f8cfe4653a6c91c0328bc2854c3 (diff) | |
download | gcc-1240df7b4075f043a00c5314318f3bbf9af719e6.zip gcc-1240df7b4075f043a00c5314318f3bbf9af719e6.tar.gz gcc-1240df7b4075f043a00c5314318f3bbf9af719e6.tar.bz2 |
alias-access-path-6.c: New testcase.
* gcc.dg/tree-ssa/alias-access-path-6.c: New testcase.
* tree-ssa-alias.c (nonoverlapping_component_refs_p): Do not
give up on bitfields; continue searching for different refs
appearing later.
From-SVN: r272587
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-6.c | 29 | ||||
-rw-r--r-- | gcc/tree-ssa-alias.c | 15 |
4 files changed, 45 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5cab328..03e1748 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-06-22 Jan Hubicka <jh@suse.cz> + + * tree-ssa-alias.c (nonoverlapping_component_refs_p): Do not + give up on bitfields; continue searching for different refs + appearing later. + 2019-06-21 Jakub Jelinek <jakub@redhat.com> * tree-vect-data-refs.c (vect_find_stmt_data_reference): Handle diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e38abbf..0b122c6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-06-22 Jan Hubicka <jh@suse.cz> + + * gcc.dg/tree-ssa/alias-access-path-6.c: New testcase. + 2019-06-22 Marek Polacek <polacek@redhat.com> PR c++/86476 - noexcept-specifier is a complete-class context. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-6.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-6.c new file mode 100644 index 0000000..c0de453 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-6.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* This tests that nonoveralpping_component_refs does not give up + on field delcs and continues looking to find mismatch between + a1 and a2. */ +struct a { + int a:3; + int b:3; +}; +struct b {struct a a1,a2;}; +struct c {struct b b[10];} *cptr; +struct d {struct c c;} *dptr; +int +test(int i,int j) +{ + cptr->b[i].a1.a=0; + dptr->c.b[j].a2.b=1; + return cptr->b[i].a1.a; +} +int +test2(int i,int j) +{ + cptr->b[i].a1.a=1; + dptr->c.b[j].a1.a=0; + return cptr->b[i].a1.a; +} +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized"} } */ +/* { dg-final { scan-tree-dump-not "return 1" "optimized"} } */ diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 111f375..3258315 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1350,19 +1350,16 @@ nonoverlapping_component_refs_p (const_tree x, const_tree y) same. */ if (DECL_BIT_FIELD_REPRESENTATIVE (fieldx) == fieldy || DECL_BIT_FIELD_REPRESENTATIVE (fieldy) == fieldx) - { - ++alias_stats.nonoverlapping_component_refs_p_may_alias; - return false; - } + ; /* Different fields of the same record type cannot overlap. ??? Bitfields can overlap at RTL level so punt on them. */ - if (DECL_BIT_FIELD (fieldx) && DECL_BIT_FIELD (fieldy)) + else if (DECL_BIT_FIELD (fieldx) && DECL_BIT_FIELD (fieldy)) + ; + else { - ++alias_stats.nonoverlapping_component_refs_p_may_alias; - return false; + ++alias_stats.nonoverlapping_component_refs_p_no_alias; + return true; } - ++alias_stats.nonoverlapping_component_refs_p_no_alias; - return true; } } if (TYPE_UID (typex) < TYPE_UID (typey)) |