libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-switch-ifcvt-1.c
blob2e3a9ae3c24919ef3e0ba9008f35178cc221de00
1 /* { dg-require-effective-target vect_condition } */
2 #include "tree-vect.h"
4 extern void abort (void);
6 int
7 f1 (char *s)
9 int c = 0;
10 int i;
11 for (i = 0; i < 64; i++)
13 switch (*s)
15 case ',':
16 case '|':
17 c++;
19 s++;
21 return c;
24 int
25 f2 (char *s)
27 int c = 0;
28 int i;
29 for (i = 0; i < 64; i++)
31 if (*s != '#')
33 switch (*s)
35 case ',':
36 case '|':
37 c++;
40 s++;
42 return c;
45 int
46 f3 (char *s)
48 int c = 0;
49 int i;
50 for (i = 0; i < 64; i++)
52 if (*s != '#')
53 if (*s == ',' || *s == '|' || *s == '@' || *s == '*')
54 c++;
55 s++;
57 return c;
61 int
62 f4 (char *s)
64 int c = 0;
65 int i;
66 for (i = 0; i < 64; i++)
68 if (*s == ',' || *s == '|' || *s == '@' || *s == '*')
69 c++;
70 s++;
72 return c;
75 #define CHECK(f, str, res) \
76 __builtin_strcpy(buf, str); n = f(buf); if (n != res) abort();
78 int
79 main ()
81 int n;
82 char buf[64];
84 __builtin_memset (buf, 0, sizeof buf);
86 check_vect ();
88 CHECK (f1, ",,,,,,,,,,", 10);
89 CHECK (f1, "||||||||||", 10);
90 CHECK (f1, "aaaaaaaaaa", 0);
91 CHECK (f1, "", 0);
92 CHECK (f1, ",|,|xxxxxx", 4);
94 CHECK (f2, ",,,,,,,,,,", 10);
95 CHECK (f2, "||||||||||", 10);
96 CHECK (f2, "aaaaaaaaaa", 0);
97 CHECK (f2, "", 0);
98 CHECK (f2, ",|,|xxxxxx", 4);
100 CHECK (f3, ",,,,,,,,,,", 10);
101 CHECK (f3, "||||||||||", 10);
102 CHECK (f3, "aaaaaaaaaa", 0);
103 CHECK (f3, "", 0);
104 CHECK (f3, ",|,|xxxxxx", 4);
106 CHECK (f4, ",,,,,,,,,,", 10);
107 CHECK (f4, "||||||||||", 10);
108 CHECK (f4, "aaaaaaaaaa", 0);
109 CHECK (f4, "", 0);
110 CHECK (f4, ",|,|xxxxxx", 4);
112 return 0;
115 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */