Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-30.c
bloba85df686ce2f68ea53970d5534bd0a69af7026bd
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-strlen" } */
4 __attribute__((no_icf))
5 _Bool f1(char *s)
7 return __builtin_strstr (s, "hello") == s;
10 __attribute__((no_icf))
11 _Bool f2(char *s)
13 return s == __builtin_strstr (s, "hello");
16 __attribute__((no_icf))
17 _Bool f3(char *s)
19 return s != __builtin_strstr (s, "hello");
22 __attribute__((no_icf))
23 _Bool f4()
25 char *foo_f4(void);
26 char *t1 = foo_f4();
27 char *t2 = __builtin_strstr (t1, "hello");
28 _Bool t3 = t2 == t1;
29 return t3;
32 __attribute__((no_icf))
33 void f5(char *s)
35 char *t1 = __builtin_strstr (s, "hello");
36 void foo_f5(void);
37 if (t1 != s)
38 foo_f5();
41 /* Do not perform transform, since strlen (t)
42 is unknown. */
44 __attribute__((no_icf))
45 _Bool f6(char *s, char *t)
47 return __builtin_strstr (s, t) == s;
50 /* Do not perform transform in this case, since
51 t1 doesn't have single use. */
53 __attribute__((no_icf))
54 _Bool f7(char *s)
56 void foo_f7(char *);
58 char *t1 = __builtin_strstr (s, "hello");
59 foo_f7 (t1);
60 return (t1 == s);
63 /* { dg-final { scan-tree-dump-times "__builtin_strncmp" 5 "strlen" } } */