1 /* This test needs runtime that provides stpcpy function. */
2 /* { dg-do run { target *-*-linux* *-*-gnu* } } */
3 /* { dg-options "-O2 -fdump-tree-strlen" } */
8 __attribute__((noinline
, noclone
)) char *
9 fn1 (int x
, int y
, int z
)
32 strcat (buf
, "ABCDEFG");
34 strcat (buf
, "HIJKLMN");
51 for (i
= 0; i
< 5; i
++)
53 const char *p
= "abcdefghijklmnopq" + (i
< 3 ? i
: 3) * 4;
56 fn1 (i
? 0 : 1, 1, 1);
58 if (memcmp (q
, p
+ 1, 3 + j
) != 0 || memcmp (q
+ 3 + j
, "RST", 4) != 0)
60 fn1 (i
? 0 : 1, 0, 1);
62 if (memcmp (q
, p
, 4 + j
) != 0 || memcmp (q
+ 4 + j
, "HIJKLMN", 8) != 0)
64 fn1 (i
? 0 : 1, 1, 0);
66 if (memcmp (q
, p
+ 1, 3 + j
) != 0 || memcmp (q
+ 3 + j
, "OPQ", 4) != 0)
68 fn1 (i
? 0 : 1, 0, 0);
70 if (memcmp (q
, p
, 4 + j
) != 0 || memcmp (q
+ 4 + j
, "ABCDEFG", 8) != 0)
76 /* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
77 /* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen" } } */
78 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
79 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
80 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
81 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 2 "strlen" } } */