2 /* { dg-options "-O2 -fdump-tree-strlen" } */
6 __attribute__((noinline
, noclone
)) char *
9 char *q
= malloc (strlen (p
) + strlen (r
) + 64);
10 if (q
== NULL
) return NULL
;
11 /* This strcpy can be optimized into memcpy, using the remembered
14 /* These two strcat can be optimized into memcpy. The first one
15 could be even optimized into a *ptr = '/'; store as the '\0'
16 is immediately overwritten. */
19 /* This can also be optimized into memcpy. */
27 char *volatile p
= "string1";
28 char *volatile r
= "string2";
32 if (strcmp (q
, "string1/abcdestring2"))
39 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen" } } */
40 /* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen" } } */
41 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
42 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
43 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
44 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
45 /* { dg-final { cleanup-tree-dump "strlen" } } */