diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2014-06-25 14:27:13 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2014-06-25 12:27:13 +0000 |
commit | 20cb2258ecac9c5cb651889966ac46f6958aec95 (patch) | |
tree | d6e6af19f60a15450ccebf23fa2ea3bd980a3b68 | |
parent | cd47dfd0c5ab8ea6464454e75740a6715a19a41d (diff) | |
download | gcc-20cb2258ecac9c5cb651889966ac46f6958aec95.zip gcc-20cb2258ecac9c5cb651889966ac46f6958aec95.tar.gz gcc-20cb2258ecac9c5cb651889966ac46f6958aec95.tar.bz2 |
re PR tree-optimization/57742 (memset(malloc(n),0,n) -> calloc(n,1))
2014-06-25 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/57742
gcc/
* tree-ssa-strlen.c (handle_builtin_memset): Update strinfo
after replacing the statement.
gcc/testsuite/
* gcc.dg/tree-ssa/calloc-3.c: New file.
From-SVN: r211977
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/calloc-3.c | 14 | ||||
-rw-r--r-- | gcc/tree-ssa-strlen.c | 2 |
4 files changed, 27 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 79847e3..45d1df4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-06-25 Marc Glisse <marc.glisse@inria.fr> + + PR tree-optimization/57742 + * tree-ssa-strlen.c (handle_builtin_memset): Update strinfo + after replacing the statement. + 2014-06-25 Nick Clifton <nickc@redhat.com> * config/v850/v850.c (GHS_default_section_names): Change to const diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 14e2017..c701691 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-06-25 Marc Glisse <marc.glisse@inria.fr> + + PR tree-optimization/57742 + * gcc.dg/tree-ssa/calloc-3.c: New file. + 2014-06-25 Richard Biener <rguenther@suse.de> PR testsuite/61560 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/calloc-3.c b/gcc/testsuite/gcc.dg/tree-ssa/calloc-3.c new file mode 100644 index 0000000..3b3b3d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/calloc-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +void*f(){ + char*p=__builtin_malloc(42); + __builtin_memset(p,0,42); + __builtin_memset(p,0,42); + return p; +}; + +/* { dg-final { scan-tree-dump-not "malloc" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "calloc" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "memset" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 6d7b852..3bc2786 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -1653,6 +1653,8 @@ handle_builtin_memset (gimple_stmt_iterator *gsi) gimple_stmt_iterator gsi1 = gsi_for_stmt (stmt1); update_gimple_call (&gsi1, builtin_decl_implicit (BUILT_IN_CALLOC), 2, size, build_one_cst (size_type_node)); + si1->length = build_int_cst (size_type_node, 0); + si1->stmt = gsi_stmt (gsi1); } else return true; |