1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-strlen" } */
3 
4 __attribute__((no_icf))
f1(char * s)5 _Bool f1(char *s)
6 {
7   return __builtin_strstr (s, "hello") == s;
8 }
9 
10 __attribute__((no_icf))
f2(char * s)11 _Bool f2(char *s)
12 {
13   return s == __builtin_strstr (s, "hello");
14 }
15 
16 __attribute__((no_icf))
f3(char * s)17 _Bool f3(char *s)
18 {
19   return s != __builtin_strstr (s, "hello");
20 }
21 
22 __attribute__((no_icf))
f4()23 _Bool f4()
24 {
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;
30 }
31 
32 __attribute__((no_icf))
f5(char * s)33 void f5(char *s)
34 {
35   char *t1 = __builtin_strstr (s, "hello");
36   void foo_f5(void);
37   if (t1 != s)
38     foo_f5();
39 }
40 
41 /* Do not perform transform, since strlen (t)
42    is unknown.  */
43 
44 __attribute__((no_icf))
f6(char * s,char * t)45 _Bool f6(char *s, char *t)
46 {
47   return __builtin_strstr (s, t) == s;
48 }
49 
50 /* Do not perform transform in this case, since
51    t1 doesn't have single use.  */
52 
53 __attribute__((no_icf))
f7(char * s)54 _Bool f7(char *s)
55 {
56   void foo_f7(char *);
57 
58   char *t1 = __builtin_strstr (s, "hello");
59   foo_f7 (t1);
60   return (t1 == s);
61 }
62 
63 /* { dg-final { scan-tree-dump-times "__builtin_strncmp" 5 "strlen" } } */
64