2 /* { dg-options "-O2 -fdump-tree-strlen" } */
6 __attribute__((noinline
, noclone
)) size_t
10 /* This can be optimized into memcpy and the size can be decreased to one,
11 as it is immediately overwritten. */
15 /* This strlen can't be optimized away, string length is unknown here. */
19 __attribute__((noinline
, noclone
)) void
20 fn2 (char *p
, const char *z
, size_t *lp
)
25 /* The first strlen stays, all the strcpy calls can be optimized
26 into memcpy and all other strlen calls and all strchr calls
46 memcpy (lp
, l
, sizeof l
);
54 const char *volatile z
= "ABCDEFG";
55 memset (buf
, '\0', sizeof buf
);
56 if (fn1 (buf
) != 2 || buf
[0] != 'z' || buf
[1] != 32 || buf
[2] != '\0')
59 if (memcmp (buf
, "abcdeefghimnopqr", 17) != 0)
63 if (l
[1] != 13 || l
[2] != 8 || l
[3] != 3)
65 if (l
[4] != 17 || l
[5] != 12 || l
[6] != 7)
67 if (l
[7] != 16 || l
[8] != 11 || l
[9] != 6)
72 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen" } } */
73 /* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op
74 to expand the memcpy call at the end of fn2. */
75 /* { dg-final { scan-tree-dump-times "memcpy \\(" 8 "strlen" { target { ! avr-*-* } } } } */
76 /* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen" { target { avr-*-* } } } } */
77 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
78 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
79 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
80 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
81 /* { dg-final { scan-tree-dump-times "\\*q_\[0-9\]* = 32;" 1 "strlen" } } */
82 /* { dg-final { scan-tree-dump-times "memcpy \\(\[^\n\r\]*, 1\\)" 1 "strlen" } } */
83 /* { dg-final { cleanup-tree-dump "strlen" } } */