1 /* This test needs runtime that provides stpcpy function. */
2 /* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
3 /* { dg-options "-O2 -fdump-tree-strlen" } */
8 __attribute__((noinline
, noclone
)) int
12 const char *q
[] = { "123498765abcde", "123498765..", "129abcde", "129abcde" };
13 if (strcmp (p
, q
[c
]) != 0)
18 __attribute__((noinline
, noclone
)) void
19 bar (const char *p
, const char *q
)
22 /* This strlen stays. */
23 char *a
= __builtin_alloca (strlen (p
) + 50);
24 /* strcpy can be optimized into memcpy. */
26 /* strcat into stpcpy. */
28 /* This strlen can be optimized away. */
30 /* This becomes memcpy. */
33 /* And this one too. */
41 const char *volatile s1
= "1234";
42 const char *volatile s2
= "98765";
43 const char *volatile s3
= "12";
44 const char *volatile s4
= "9";
50 /* { dg-final { scan-tree-dump-times "strlen \\(" 1 "strlen1" } } */
51 /* { dg-final { scan-tree-dump-times "memcpy \\(" 3 "strlen1" } } */
52 /* { dg-final { scan-tree-dump-times "mempcpy \\(" 0 "strlen1" } } */
53 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */
54 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */
55 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */
56 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 1 "strlen1" } } */