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
)) char *
9 fn1 (char *p
, const char *q
)
11 /* This strcpy can be optimized into stpcpy. */
13 /* And this strchr into the return value from it. */
14 return strchr (p
, '\0');
21 const char *volatile q
= "ABCDEFGH";
22 if (fn1 (buf
, q
) != buf
+ 8 || memcmp (buf
, "ABCDEFGH", 9) != 0)
27 /* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */
28 /* { dg-final { scan-tree-dump-times "memcpy \\(" 0 "strlen1" } } */
29 /* { dg-final { scan-tree-dump-times "mempcpy \\(" 0 "strlen1" } } */
30 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */
31 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */
32 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */
33 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 1 "strlen1" } } */