diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-05-13 09:46:53 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-05-13 09:46:53 +0200 |
commit | 3a60f32bdee43dcadac21f4e51ce0c43d7aa84a3 (patch) | |
tree | cae85acf0ab04899986e663a8d8d8a547e8e19d7 | |
parent | 2710a27af098557e37d3d131fa5a43dbfddab408 (diff) | |
download | gcc-3a60f32bdee43dcadac21f4e51ce0c43d7aa84a3.zip gcc-3a60f32bdee43dcadac21f4e51ce0c43d7aa84a3.tar.gz gcc-3a60f32bdee43dcadac21f4e51ce0c43d7aa84a3.tar.bz2 |
re PR tree-optimization/57230 (tree-ssa-strlen incorrectly optimizes a strlen to 0)
PR tree-optimization/57230
* tree-ssa-strlen.c (handle_char_store): Add missing integer_zerop
check.
* gcc.dg/strlenopt-23.c: New test.
From-SVN: r198813
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/strlenopt-23.c | 15 | ||||
-rw-r--r-- | gcc/tree-ssa-strlen.c | 2 |
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 51deae8..2d1bbea 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-05-13 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/57230 + * tree-ssa-strlen.c (handle_char_store): Add missing integer_zerop + check. + 2013-05-12 Joern Rennecke <joern.rennecke@embecosm.com> * config/epiphany/epiphany.c (epiphany_init): Check size of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 424f687..52ccf1a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-05-13 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/57230 + * gcc.dg/strlenopt-23.c: New test. + 2013-05-12 Oleg Endo <olegendo@gcc.gnu.org> PR target/57108 diff --git a/gcc/testsuite/gcc.dg/strlenopt-23.c b/gcc/testsuite/gcc.dg/strlenopt-23.c new file mode 100644 index 0000000..75dab2a --- /dev/null +++ b/gcc/testsuite/gcc.dg/strlenopt-23.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/57230 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "strlenopt.h" + +int +main () +{ + char p[] = "hello world"; + p[0] = (char) (strlen (p) - 1); + if (strlen (p) != 11) + abort (); + return 0; +} diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index bea0c28..4b6cfda 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -1703,7 +1703,7 @@ handle_char_store (gimple_stmt_iterator *gsi) its length may be decreased. */ adjust_last_stmt (si, stmt, false); } - else if (si != NULL) + else if (si != NULL && integer_zerop (gimple_assign_rhs1 (stmt))) { si = unshare_strinfo (si); si->length = build_int_cst (size_type_node, 0); |