From: Richard Biener Date: Fri, 1 Jun 2018 10:49:54 +0000 (+0000) Subject: re PR tree-optimization/86017 (multiple consecutive calls to bzero/memset not merged) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=47cac108ef3a44811ae56fb9c823d5a2339d751b;p=gcc.git re PR tree-optimization/86017 (multiple consecutive calls to bzero/memset not merged) 2018-06-01 Richard Biener PR middle-end/86017 * gimple-fold.c (var_decl_component_p): Also allow offsetted vars wrapped in MEM_REFs. * gcc.dg/tree-ssa/pr86017.c: New testcase. From-SVN: r261061 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9035e67cd99..8806024a5ae 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-06-01 Richard Biener + + PR middle-end/86017 + * gimple-fold.c (var_decl_component_p): Also allow offsetted + vars wrapped in MEM_REFs. + 2018-06-01 Richard Sandiford * config/aarch64/aarch64.c (aarch64_ira_change_pseudo_allocno_class): diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 9bbe7f1d909..f6d758a6828 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -632,7 +632,9 @@ var_decl_component_p (tree var) tree inner = var; while (handled_component_p (inner)) inner = TREE_OPERAND (inner, 0); - return SSA_VAR_P (inner); + return (DECL_P (inner) + || (TREE_CODE (inner) == MEM_REF + && TREE_CODE (TREE_OPERAND (inner, 0)) == ADDR_EXPR)); } /* If the SIZE argument representing the size of an object is in a range diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cec80a5d238..12ed15f42d9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-01 Richard Biener + + PR middle-end/86017 + * gcc.dg/tree-ssa/pr86017.c: New testcase. + 2018-06-01 Richard Biener PR ipa/85960 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr86017.c b/gcc/testsuite/gcc.dg/tree-ssa/pr86017.c new file mode 100644 index 00000000000..f216e83c7b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr86017.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +void f (void*); + +void g (void) +{ + char a[8]; + __builtin_memset (a, 0, 8); + + f (a); +} + +void h (void) +{ + char a[8]; + __builtin_memset (a, 0, 1); + __builtin_memset (a + 1, 0, 1); + __builtin_memset (a + 2, 0, 1); + __builtin_memset (a + 3, 0, 1); + __builtin_memset (a + 4, 0, 1); + __builtin_memset (a + 5, 0, 1); + __builtin_memset (a + 6, 0, 1); + __builtin_memset (a + 7, 0, 1); + + f (a); +} + +/* { dg-final { scan-tree-dump "Merged into 1 stores" "store-merging" } } */