2 /* { dg-options "-O2 -fdump-tree-strlen" } */
6 /* If stpcpy can't be used, this is optimized into
7 strcpy (p, q); strcat (p, r); memcpy (p + strlen (p), "abcd", 5);
8 If stpcpy can be used (see strlenopt-4g.c test),
10 memcpy (stpcpy (stpcpy (p, q), r), "abcd", 5); */
11 __attribute__((noinline
, noclone
)) void
12 foo (char *p
, const char *q
, const char *r
)
19 /* If stpcpy can't be used, this is optimized into
20 memcpy (p, "abcd", 4); strcpy (p + 4, q); strcat (p, r);
21 If stpcpy can be used, this is optimized into
22 memcpy (p, "abcd", 4); strcpy (stpcpy (p + 4, q), r); */
23 __attribute__((noinline
, noclone
)) void
24 bar (char *p
, const char *q
, const char *r
)
31 /* If stpcpy can't be used, this is optimized into
32 strcat (p, q); memcpy (t1 = p + strlen (p), "abcd", 4);
33 strcpy (t1 + 4, r); memcpy (p + strlen (p), "efgh", 5);
34 If stpcpy can be used, this is optimized into
35 t1 = stpcpy (p + strlen (p), q); memcpy (t1, "abcd", 4);
36 memcpy (stpcpy (t1 + 4, r), "efgh", 5); */
37 __attribute__((noinline
, noclone
)) void
38 baz (char *p
, const char *q
, const char *r
)
51 char *volatile p
= buf
;
52 const char *volatile q
= "ij";
53 const char *volatile r
= "klmno";
55 if (memcmp (buf
, "ijklmnoabcd\0\0\0\0\0\0\0\0", 20) != 0)
57 memset (buf
, '\0', sizeof buf
);
59 if (memcmp (buf
, "abcdijklmno\0\0\0\0\0\0\0\0", 20) != 0)
62 memset (buf
+ 3, '\0', -3 + sizeof buf
);
64 if (memcmp (buf
, "vvvijabcdklmnoefgh\0", 20) != 0)
69 /* For targets providing a movstr pattern strcat is already decomposed
70 into strlen + strcpy by fold_builtin_strcat. */
72 /* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen" { target { ! s390*-*-* } } } } */
73 /* { dg-final { scan-tree-dump-times "strlen \\(" 6 "strlen" { target s390*-*-* } } } */
74 /* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen" } } */
75 /* { dg-final { scan-tree-dump-times "strcpy \\(" 3 "strlen" { target { ! s390*-*-* } } } } */
76 /* { dg-final { scan-tree-dump-times "strcpy \\(" 6 "strlen" { target s390*-*-* } } } */
77 /* { dg-final { scan-tree-dump-times "strcat \\(" 3 "strlen" { target { ! s390*-*-* } } } } */
78 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" { target s390*-*-* } } } */
79 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
80 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
81 /* { dg-final { cleanup-tree-dump "strlen" } } */