PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / strcmpopt_3.c
blob86a0d7a08b3a4c081d83c782b1e586e9694d1318
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fdump-tree-strlen" } */
4 __attribute__ ((noinline)) int
5 f1 (void)
6 {
7 char *s0= "abcd";
8 char s[8];
9 __builtin_strcpy (s, s0);
10 return __builtin_strcmp(s, "abc") != 0;
13 __attribute__ ((noinline)) int
14 f2 (void)
16 char *s0 = "ab";
17 char s[8];
18 __builtin_strcpy (s, s0);
19 return __builtin_strcmp("abc", s) != 0;
22 int main (void)
24 if (f1 () != 1
25 || f2 () != 1)
26 __builtin_abort ();
28 return 0;
31 /* { dg-final { scan-tree-dump-times "strcmp" 0 "strlen" } } */