2 /* { dg-options "-O2 -fdump-tree-strlen" } */
6 __attribute__((noinline
, noclone
)) void
7 fn1 (char *p
, const char *z
, size_t *lp
)
12 /* The first strlen stays, all the strcpy calls can be optimized
13 into memcpy and most other strlen calls and all strchr calls
14 optimized away. l[6] = strlen (r); and l[9] = strlen (r); need
15 to stay, because we need to invalidate the knowledge about
16 r strlen after strcpy (q, "jklmnopqrst"). */
27 strcpy (q
, "jklmnopqrst");
37 memcpy (lp
, l
, sizeof l
);
45 const char *volatile z
= "ABCDEFG";
46 memset (buf
, '\0', sizeof buf
);
48 if (memcmp (buf
, "abcdejklmnopqrstABCDEFG", 24) != 0)
52 if (l
[1] != 17 || l
[2] != 12 || l
[3] != 7)
54 if (l
[4] != 16 || l
[5] != 11 || l
[6] != 6)
56 if (l
[7] != 23 || l
[8] != 18 || l
[9] != 13 || l
[10] != 7)
61 /* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen" } } */
62 /* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op
63 to expand the memcpy call at the end of fn1. */
64 /* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen" { target { ! avr-*-* } } } } */
65 /* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen" { target { avr-*-* } } } } */
66 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
67 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
68 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
69 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
70 /* Where the memcpy is expanded, the assignemts to elements of l are
72 /* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.0. = " 1 "strlen" { target { ! avr-*-* } } } } */
73 /* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.6. = " 1 "strlen" { target { ! avr-*-* } } } } */
74 /* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.9. = " 1 "strlen" { target { ! avr-*-* } } } } */
75 /* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;" 3 "strlen" { target { avr-*-* } } } } */