2 /* { dg-options "-O2 -fdump-tree-strlen -fdump-tree-optimized" } */
6 __attribute__((noinline
, noclone
)) size_t
11 return s
- strlen (p
);
14 __attribute__((noinline
, noclone
)) size_t
15 fn2 (char *p
, char *q
)
17 size_t s
= strlen (q
);
19 return s
- strlen (p
);
22 __attribute__((noinline
, noclone
)) size_t
25 memcpy (p
, "abcd", 5);
29 __attribute__((noinline
, noclone
)) size_t
32 memcpy (p
, "efg\0hij", 6);
40 char *volatile p
= buf
;
41 char *volatile q
= "ABCDEF";
43 if (fn1 (p
, q
) != 0 || memcmp (buf
, "ABCDEF\0G", 8))
46 if (fn2 (p
+ 1, q
) != 0 || memcmp (buf
, "AHIJ\0F\0G", 8))
49 if (fn3 (p
+ 1) != 4 || memcmp (buf
, "Aabcd\0KG", 8))
51 if (fn4 (p
) != 3 || memcmp (buf
, "efg\0hiKG", 8))
56 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen" } } */
57 /* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen" } } */
58 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
59 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
60 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
61 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
62 /* { dg-final { scan-tree-dump-times "return 0" 3 "optimized" } } */
63 /* { dg-final { scan-tree-dump-times "return 4" 1 "optimized" } } */
64 /* { dg-final { scan-tree-dump-times "return 3" 1 "optimized" } } */