+2016-06-30 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/71707
+ * tree-ssa-strlen.c (get_stridx_plus_constant): Handle already present
+ strinfo even for ADDR_EXPR ptr.
+
2016-06-30 Kelvin Nilsen <kelvin@gcc.gnu.org>
* config/rs6000/altivec.md (darn_32): Change the condition to
2016-06-30 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/71707
+ * gcc.dg/strlenopt-29.c: New test.
+
PR fortran/71704
* gfortran.dg/gomp/pr71704.f90: New test.
--- /dev/null
+/* PR tree-optimization/71707 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fdump-tree-strlen" } */
+
+#include "strlenopt.h"
+
+char a[32];
+size_t b;
+
+__attribute__((noinline, noclone)) char *
+foo (void)
+{
+ char *p = memcpy (a, "a", 2) + 1;
+ memcpy (&a[1], "b", 2);
+ b = strlen (a) + strlen (&a[1]) + strlen (p);
+ return p;
+}
+
+int
+main ()
+{
+ if (foo () != &a[1] || b != 4)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
{
if (r == 0)
{
- gcc_assert (TREE_CODE (ptr) == SSA_NAME);
- ssa_ver_to_stridx[SSA_NAME_VERSION (ptr)] = si->idx;
+ if (TREE_CODE (ptr) == SSA_NAME)
+ ssa_ver_to_stridx[SSA_NAME_VERSION (ptr)] = si->idx;
+ else
+ {
+ int *pidx = addr_stridxptr (TREE_OPERAND (ptr, 0));
+ if (pidx != NULL && *pidx == 0)
+ *pidx = si->idx;
+ }
return si->idx;
}
break;