1 /* { dg-require-effective-target vect_cond_mixed } */
2 /* { dg-require-effective-target vect_float } */
3 /* { dg-additional-options "-fno-ipa-icf" } */
4
5 #include "tree-vect.h"
6
7 #define N 1024
8 float a[N], b[N], c[N], d[N];
9 int j[N];
10 unsigned char k[N];
11
12 __attribute__((noinline, noclone)) void
f1(void)13 f1 (void)
14 {
15 int i;
16 for (i = 0; i < N; ++i)
17 {
18 unsigned int x = a[i] < b[i] ? -1 : 0;
19 unsigned int y = c[i] < d[i] ? -1 : 0;
20 j[i] = (x & y) >> 31;
21 }
22 }
23
24 __attribute__((noinline, noclone)) void
f2(void)25 f2 (void)
26 {
27 int i;
28 for (i = 0; i < N; ++i)
29 {
30 int x = a[i] < b[i];
31 int y = c[i] < d[i];
32 j[i] = x & y;
33 }
34 }
35
36 __attribute__((noinline, noclone)) void
f3(void)37 f3 (void)
38 {
39 int i;
40 for (i = 0; i < N; ++i)
41 j[i] = (a[i] < b[i]) & (c[i] < d[i]);
42 }
43
44 __attribute__((noinline, noclone)) void
f4(void)45 f4 (void)
46 {
47 int i;
48 for (i = 0; i < N; ++i)
49 {
50 int x = a[i] < b[i];
51 int y = c[i] < d[i];
52 k[i] = x & y;
53 }
54 }
55
56 __attribute__((noinline, noclone)) void
f5(void)57 f5 (void)
58 {
59 int i;
60 for (i = 0; i < N; ++i)
61 k[i] = (a[i] < b[i]) & (c[i] < d[i]);
62 }
63
64 __attribute__((noinline, noclone)) void
f6(void)65 f6 (void)
66 {
67 int i;
68 for (i = 0; i < N; ++i)
69 {
70 unsigned int x = a[i] < b[i] ? -1 : 0;
71 unsigned int y = c[i] < d[i] ? -1 : 0;
72 j[i] = (x | y) >> 31;
73 }
74 }
75
76 __attribute__((noinline, noclone)) void
f7(void)77 f7 (void)
78 {
79 int i;
80 for (i = 0; i < N; ++i)
81 {
82 int x = a[i] < b[i];
83 int y = c[i] < d[i];
84 j[i] = x | y;
85 }
86 }
87
88 __attribute__((noinline, noclone)) void
f8(void)89 f8 (void)
90 {
91 int i;
92 for (i = 0; i < N; ++i)
93 j[i] = (a[i] < b[i]) | (c[i] < d[i]);
94 }
95
96 __attribute__((noinline, noclone)) void
f9(void)97 f9 (void)
98 {
99 int i;
100 for (i = 0; i < N; ++i)
101 {
102 int x = a[i] < b[i];
103 int y = c[i] < d[i];
104 k[i] = x | y;
105 }
106 }
107
108 __attribute__((noinline, noclone)) void
f10(void)109 f10 (void)
110 {
111 int i;
112 for (i = 0; i < N; ++i)
113 k[i] = (a[i] < b[i]) | (c[i] < d[i]);
114 }
115
116 int
main()117 main ()
118 {
119 int i;
120
121 check_vect ();
122
123 for (i = 0; i < N; i++)
124 {
125 switch (i % 9)
126 {
127 case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break;
128 case 1: a[i] = 0; b[i] = 0; break;
129 case 2: a[i] = i + 1; b[i] = - i - 1; break;
130 case 3: a[i] = i; b[i] = i + 7; break;
131 case 4: a[i] = i; b[i] = i; break;
132 case 5: a[i] = i + 16; b[i] = i + 3; break;
133 case 6: a[i] = - i - 5; b[i] = - i; break;
134 case 7: a[i] = - i; b[i] = - i; break;
135 case 8: a[i] = - i; b[i] = - i - 7; break;
136 }
137 }
138 for (i = 0; i < N; i++)
139 {
140 switch ((i / 9) % 3)
141 {
142 case 0: c[i] = a[i / 9]; d[i] = b[i / 9]; break;
143 case 1: c[i] = a[i / 9 + 3]; d[i] = b[i / 9 + 3]; break;
144 case 2: c[i] = a[i / 9 + 6]; d[i] = b[i / 9 + 6]; break;
145 }
146 }
147 f1 ();
148 for (i = 0; i < N; i++)
149 if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
150 abort ();
151 __builtin_memset (j, -6, sizeof (j));
152 f2 ();
153 for (i = 0; i < N; i++)
154 if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
155 abort ();
156 __builtin_memset (j, -6, sizeof (j));
157 f3 ();
158 for (i = 0; i < N; i++)
159 if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
160 abort ();
161 __builtin_memset (j, -6, sizeof (j));
162 f4 ();
163 for (i = 0; i < N; i++)
164 if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
165 abort ();
166 __builtin_memset (k, -6, sizeof (k));
167 f5 ();
168 for (i = 0; i < N; i++)
169 if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
170 abort ();
171 __builtin_memset (k, -6, sizeof (k));
172 f6 ();
173 for (i = 0; i < N; i++)
174 if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
175 abort ();
176 __builtin_memset (j, -6, sizeof (j));
177 f7 ();
178 for (i = 0; i < N; i++)
179 if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
180 abort ();
181 __builtin_memset (j, -6, sizeof (j));
182 f8 ();
183 for (i = 0; i < N; i++)
184 if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
185 abort ();
186 __builtin_memset (j, -6, sizeof (j));
187 f9 ();
188 for (i = 0; i < N; i++)
189 if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
190 abort ();
191 __builtin_memset (k, -6, sizeof (k));
192 f10 ();
193 for (i = 0; i < N; i++)
194 if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
195 abort ();
196 __builtin_memset (k, -6, sizeof (k));
197
198 return 0;
199 }
200
201 /* { dg-final { scan-tree-dump-times "note: vectorized 1 loops" 10 "vect" } } */
202