2013-05-13 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/57230
+ * tree-ssa-strlen.c (handle_char_store): Record length for
+ array store from STRING_CST.
+
+ PR tree-optimization/57230
* tree-ssa-strlen.c (handle_char_store): Add missing integer_zerop
check.
2013-05-13 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/57230
+ * gcc.dg/strlenopt-24.c: New test.
+
+ PR tree-optimization/57230
* gcc.dg/strlenopt-23.c: New test.
2013-05-12 Oleg Endo <olegendo@gcc.gnu.org>
--- /dev/null
+/* PR tree-optimization/57230 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fdump-tree-strlen" } */
+
+#include "strlenopt.h"
+
+int
+main ()
+{
+ char p[] = "hello world";
+ if (strlen (p) != 11)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } *
+/* { dg-final { cleanup-tree-dump "strlen" } } */
if (si != NULL)
si->writable = true;
}
+ else if (idx == 0
+ && TREE_CODE (gimple_assign_rhs1 (stmt)) == STRING_CST
+ && ssaname == NULL_TREE
+ && TREE_CODE (TREE_TYPE (lhs)) == ARRAY_TYPE)
+ {
+ size_t l = strlen (TREE_STRING_POINTER (gimple_assign_rhs1 (stmt)));
+ HOST_WIDE_INT a = int_size_in_bytes (TREE_TYPE (lhs));
+ if (a > 0 && (unsigned HOST_WIDE_INT) a > l)
+ {
+ int idx = new_addr_stridx (lhs);
+ if (idx != 0)
+ {
+ si = new_strinfo (build_fold_addr_expr (lhs), idx,
+ build_int_cst (size_type_node, l));
+ set_strinfo (idx, si);
+ si->dont_invalidate = true;
+ }
+ }
+ }
if (si != NULL && initializer_zerop (gimple_assign_rhs1 (stmt)))
{