2 /* { dg-options "-O2 -fdump-tree-strlen" } */
9 size_t __attribute__ ((noinline
, noclone
))
14 memcpy (a
, "1234567", 7);
15 memcpy (a
+ 7, "89abcdefg", 9);
16 memcpy (a
+ 16, "h", 2);
17 return strlen (a
); // This strlen should be optimized into 17.
20 size_t __attribute__ ((noinline
, noclone
))
24 memcpy (a
, "1234567", 7);
25 memcpy (a
+ 7, "89abcdefg", 9);
26 memcpy (a
+ 16, "h", 2);
27 return strlen (a
); // This strlen should be optimized into 17.
30 size_t __attribute__ ((noinline
, noclone
))
36 memcpy (a
+ 1, "2345678", 8);
37 return strlen (a
); // This strlen should be optimized into 8.
40 size_t __attribute__ ((noinline
, noclone
))
45 memcpy (a
+ 1, "2345678", 8);
46 return strlen (a
); // This strlen should be optimized into 8.
49 size_t __attribute__ ((noinline
, noclone
))
57 memcpy (a
+ 3, "456", 3);
60 return strlen (a
); // This strlen should be optimized into 7.
63 size_t __attribute__ ((noinline
, noclone
))
70 memcpy (a
+ 3, "456", 3);
73 return strlen (a
); // This strlen should be optimized into 7.
76 size_t __attribute__ ((noinline
, noclone
))
82 int len1
= strlen (a
);
84 int len2
= strlen (a
);
85 return len1
+ len2
; // This should be optimized into 10.
88 size_t __attribute__ ((noinline
, noclone
))
93 int len1
= strlen (a
);
95 int len2
= strlen (a
);
96 return len1
+ len2
; // This should be optimized into 10.
99 size_t __attribute__ ((noinline
, noclone
))
104 strcpy (a
, "foo.bar");
107 return strlen (a
); // This should be optimized into 3.
110 size_t __attribute__ ((noinline
, noclone
))
111 f10 (char *a
, char b
)
114 strcpy (a
, "foo.bar");
117 return strlen (a
); // This should be optimized into 3.
120 size_t __attribute__ ((noinline
, noclone
))
125 strcpy (temp
, "123456");
127 return strlen (a
); // This should be optimized into 6.
130 size_t __attribute__ ((noinline
, noclone
))
134 strcpy (temp
, "123456");
136 return strlen (a
); // This should be optimized into 6.
139 size_t __attribute__ ((noinline
, noclone
))
144 strcpy (temp
, "1234567");
147 return strlen (a
); // This should be optimized into 7.
150 size_t __attribute__ ((noinline
, noclone
))
154 strcpy (temp
, "1234567");
157 return strlen (a
); // This should be optimized into 7.
160 size_t __attribute__ ((noinline
, noclone
))
165 strcpy (temp
, "12345679");
168 return strlen (a
); // This should be optimized into 7.
171 size_t __attribute__ ((noinline
, noclone
))
175 strcpy (temp
, "123456789");
178 return strlen (a
); // This should be optimized into 7.
185 if (f1 () != 17 || f2 (a
) != 17 || f3 () != 8 || f4 (a
) != 8
186 || f5 () != 7 || f6 (a
) != 7 || f7 () != 10 || f8 (a
) != 10
187 || f9 ('_') != 3 || f10 (a
, '_') != 3 || f11 () != 6 || f12 (a
) != 6
188 || f13 () != 7 || f14 (a
) != 7 || f15 () != 7 || f16 (a
) != 7)
193 /* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */