Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-bool-cmp.c
bloba1be71167025c960fc2304878c1ed15d90484dfb
1 /* PR tree-optimization/71488 */
2 /* { dg-require-effective-target vect_int } */
3 /* { dg-require-effective-target vect_pack_trunc } */
4 /* { dg-additional-options "-msse4" { target sse4_runtime } } */
6 #include "tree-vect.h"
8 int i1, i2;
10 void __attribute__((noclone,noinline))
11 fn1 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size)
13 int i;
15 for (i = 0; i < size; i++)
16 p1[i] = ((p2[i] == 0) > (unsigned)(p3[i] == 0)) + (p2[i] == 0);
19 void __attribute__((noclone,noinline))
20 fn2 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size)
22 int i;
24 for (i = 0; i < size; i++)
25 p1[i] = ((p2[i] == 0) > (unsigned)(p3[i] == 0)) + (p2[i] == 0);
28 void __attribute__((noclone,noinline))
29 fn3 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size)
31 int i;
33 for (i = 0; i < size; i++)
34 p1[i] = ((p2[i] == 0) > (unsigned)(p3[i] == 0)) + (p2[i] == 0);
37 void __attribute__((noclone,noinline))
38 fn4 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size)
40 int i;
42 for (i = 0; i < size; i++)
43 p1[i] = ((p2[i] == 0) >= (unsigned)(p3[i] == 0)) + (p2[i] == 0);
46 void __attribute__((noclone,noinline))
47 fn5 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size)
49 int i;
51 for (i = 0; i < size; i++)
52 p1[i] = ((p2[i] == 0) >= (unsigned)(p3[i] == 0)) + (p2[i] == 0);
55 void __attribute__((noclone,noinline))
56 fn6 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size)
58 int i;
60 for (i = 0; i < size; i++)
61 p1[i] = ((p2[i] == 0) >= (unsigned)(p3[i] == 0)) + (p2[i] == 0);
64 void __attribute__((noclone,noinline))
65 fn7 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size)
67 int i;
69 for (i = 0; i < size; i++)
70 p1[i] = ((p2[i] == 0) < (unsigned)(p3[i] == 0)) + (p2[i] == 0);
73 void __attribute__((noclone,noinline))
74 fn8 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size)
76 int i;
78 for (i = 0; i < size; i++)
79 p1[i] = ((p2[i] == 0) < (unsigned)(p3[i] == 0)) + (p2[i] == 0);
82 void __attribute__((noclone,noinline))
83 fn9 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size)
85 int i;
87 for (i = 0; i < size; i++)
88 p1[i] = ((p2[i] == 0) < (unsigned)(p3[i] == 0)) + (p2[i] == 0);
91 void __attribute__((noclone,noinline))
92 fn10 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size)
94 int i;
96 for (i = 0; i < size; i++)
97 p1[i] = ((p2[i] == 0) <= (unsigned)(p3[i] == 0)) + (p2[i] == 0);
100 void __attribute__((noclone,noinline))
101 fn11 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size)
103 int i;
105 for (i = 0; i < size; i++)
106 p1[i] = ((p2[i] == 0) <= (unsigned)(p3[i] == 0)) + (p2[i] == 0);
109 void __attribute__((noclone,noinline))
110 fn12 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size)
112 int i;
114 for (i = 0; i < size; i++)
115 p1[i] = ((p2[i] == 0) <= (unsigned)(p3[i] == 0)) + (p2[i] == 0);
118 void __attribute__((noclone,noinline))
119 fn13 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size)
121 int i;
123 for (i = 0; i < size; i++)
124 p1[i] = ((p2[i] == 0) == (unsigned)(p3[i] == 0)) + (p2[i] == 0);
127 void __attribute__((noclone,noinline))
128 fn14 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size)
130 int i;
132 for (i = 0; i < size; i++)
133 p1[i] = ((p2[i] == 0) == (unsigned)(p3[i] == 0)) + (p2[i] == 0);
136 void __attribute__((noclone,noinline))
137 fn15 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size)
139 int i;
141 for (i = 0; i < size; i++)
142 p1[i] = ((p2[i] == 0) == (unsigned)(p3[i] == 0)) + (p2[i] == 0);
145 void __attribute__((noclone,noinline))
146 fn16 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size)
148 int i;
150 for (i = 0; i < size; i++)
151 p1[i] = ((p2[i] == 0) != (unsigned)(p3[i] == 0)) + (p2[i] == 0);
154 void __attribute__((noclone,noinline))
155 fn17 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size)
157 int i;
159 for (i = 0; i < size; i++)
160 p1[i] = ((p2[i] == 0) != (unsigned)(p3[i] == 0)) + (p2[i] == 0);
163 void __attribute__((noclone,noinline))
164 fn18 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size)
166 int i;
168 for (i = 0; i < size; i++)
169 p1[i] = ((p2[i] == 0) != (unsigned)(p3[i] == 0)) + (p2[i] == 0);
172 int eq (int i1, int i2) { return i1 == i2; }
173 int ne (int i1, int i2) { return i1 != i2; }
174 int lt (int i1, int i2) { return i1 < i2; }
175 int le (int i1, int i2) { return i1 <= i2; }
176 int gt (int i1, int i2) { return i1 > i2; }
177 int ge (int i1, int i2) { return i1 >= i2; }
179 typedef int (*cmp_fn)(int, int);
181 void
182 check (int *p, cmp_fn fn)
184 int i;
186 #pragma GCC novector
187 for (i = 0; i < 32; i++)
189 int t1 = ((i % 4) > 1) == 0;
190 int t2 = (i % 2) == 0;
191 int res = fn (t1, t2) + t1;
192 if (p[i] != res)
193 __builtin_abort ();
198 main (int argc, char **argv)
200 int i1[32], i2[32], res[32];
201 short s2[32];
202 long long l2[32];
203 int i;
205 check_vect ();
207 for (i = 0; i < 32; i++)
209 l2[i] = i2[i] = s2[i] = i % 2;
210 i1[i] = (i % 4) > 1;
211 asm ("":::"memory");
214 fn1 (res, i1, i2, 32);
215 check (res, gt);
216 fn2 (res, i1, s2, 32);
217 check (res, gt);
218 fn3 (res, i1, l2, 32);
219 check (res, gt);
221 fn4 (res, i1, i2, 32);
222 check (res, ge);
223 fn5 (res, i1, s2, 32);
224 check (res, ge);
225 fn6 (res, i1, l2, 32);
226 check (res, ge);
228 fn7 (res, i1, i2, 32);
229 check (res, lt);
230 fn8 (res, i1, s2, 32);
231 check (res, lt);
232 fn9 (res, i1, l2, 32);
233 check (res, lt);
235 fn10 (res, i1, i2, 32);
236 check (res, le);
237 fn11 (res, i1, s2, 32);
238 check (res, le);
239 fn12 (res, i1, l2, 32);
240 check (res, le);
242 fn13 (res, i1, i2, 32);
243 check (res, eq);
244 fn14 (res, i1, s2, 32);
245 check (res, eq);
246 fn15 (res, i1, l2, 32);
247 check (res, eq);
249 fn16 (res, i1, i2, 32);
250 check (res, ne);
251 fn17 (res, i1, s2, 32);
252 check (res, ne);
253 fn18 (res, i1, l2, 32);
254 check (res, ne);
257 /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 18 "vect" { target sse4_runtime } } } */