2 /* { dg-options "-O2 -fdump-tree-strlen" } */
6 __attribute__((noinline
, noclone
)) void
7 fn1 (char *p
, const char *y
, const char *z
, size_t *lp
)
10 char buf1
[64], buf2
[64];
12 /* These two strlen calls stay, all strcpy calls are optimized into
13 memcpy, all strchr calls optimized away, and most other strlen
28 /* Except for these two calls, strlen (r) before and after the above
29 is non-constant, so adding l[4] - l[1] to all previous strlens
30 might make the expressions already too complex. */
33 /* This one is of course optimized, it is l[1]. */
35 memcpy (lp
, l
, sizeof l
);
43 const char *volatile y
= "ABCDEFG";
44 const char *volatile z
= "HIJK";
45 memset (buf
, '\0', sizeof buf
);
47 if (memcmp (buf
, "abcdeefghiHIJK", 15) != 0)
49 if (l
[0] != 7 || l
[1] != 4)
51 if (l
[2] != 17 || l
[3] != 12 || l
[4] != 7)
53 if (l
[5] != 14 || l
[6] != 9 || l
[7] != 4)
58 /* { dg-final { scan-tree-dump-times "strlen \\(" 4 "strlen" } } */
59 /* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op
60 to expand the memcpy call at the end of fn1. */
61 /* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen" { target { ! avr-*-* } } } } */
62 /* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen" { target { avr-*-* } } } } */
63 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
64 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
65 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
66 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
67 /* Where the memcpy is expanded, the assignemts to elements of l are
69 /* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.0. = " 1 "strlen" { target { ! avr-*-* } } } } */
70 /* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.1. = " 1 "strlen" { target { ! avr-*-* } } } } */
71 /* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.5. = " 1 "strlen" { target { ! avr-*-* } } } } */
72 /* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.6. = " 1 "strlen" { target { ! avr-*-* } } } } */
73 /* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;" 4 "strlen" { target { avr-*-* } } } } */