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 /* Due to inefficient PTA (PR50262) the above calls invalidate
20 string length of r, so it is optimized just into strcpy instead
29 char *volatile p = "string1";
30 char *volatile r = "string2";
34 if (strcmp (q, "string1/abcdestring2"))
41 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen" } } */
42 /* { dg-final { scan-tree-dump-times "memcpy \\(" 3 "strlen" } } */
43 /* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen" } } */
44 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
45 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
46 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
47 /* { dg-final { cleanup-tree-dump "strlen" } } */