2 /* { dg-options "-O2 -fdump-tree-strlen" } */
6 struct S
{ char *p
; size_t l
; };
8 __attribute__((noinline
, noclone
)) struct S
13 char *p
= strchr (x
, '\0');
15 /* strcpy here is optimized into memcpy, length computed as p - x + 1. */
17 /* strcat here is optimized into memcpy. */
19 for (i
= 0; i
< n
; i
++)
21 /* strcat here is optimized into strlen and memcpy. */
24 /* The strlen should be optimized here into 4. */
37 if (s
.l
!= 4 || memcmp (buf
, "zabcd", 6) != 0)
41 if (memcmp (s
.p
, "z", 2) != 0)
44 if (s
.l
!= 4 || memcmp (buf
, "zabcdabcd", 10) != 0)
48 if (memcmp (s
.p
, "zabcdefg", 9) != 0)
51 if (s
.l
!= 4 || memcmp (buf
, "zabcdabcdabcd", 14) != 0)
55 if (memcmp (s
.p
, "zabcdabcdefgefg", 16) != 0)
60 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen" } } */
61 /* { dg-final { scan-tree-dump-times "memcpy \\(" 3 "strlen" } } */
62 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
63 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
64 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
65 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */