PR tree-optimization/84740
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-bool-cmp.c
blob35d2a3ca02e948cba9c83467cd0e34e44dbe0b09
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 for (i = 0; i < 32; i++)
188 int t1 = ((i % 4) > 1) == 0;
189 int t2 = (i % 2) == 0;
190 int res = fn (t1, t2) + t1;
191 if (p[i] != res)
192 __builtin_abort ();
197 main (int argc, char **argv)
199 int i1[32], i2[32], res[32];
200 short s2[32];
201 long long l2[32];
202 int i;
204 check_vect ();
206 for (i = 0; i < 32; i++)
208 l2[i] = i2[i] = s2[i] = i % 2;
209 i1[i] = (i % 4) > 1;
210 asm ("":::"memory");
213 fn1 (res, i1, i2, 32);
214 check (res, gt);
215 fn2 (res, i1, s2, 32);
216 check (res, gt);
217 fn3 (res, i1, l2, 32);
218 check (res, gt);
220 fn4 (res, i1, i2, 32);
221 check (res, ge);
222 fn5 (res, i1, s2, 32);
223 check (res, ge);
224 fn6 (res, i1, l2, 32);
225 check (res, ge);
227 fn7 (res, i1, i2, 32);
228 check (res, lt);
229 fn8 (res, i1, s2, 32);
230 check (res, lt);
231 fn9 (res, i1, l2, 32);
232 check (res, lt);
234 fn10 (res, i1, i2, 32);
235 check (res, le);
236 fn11 (res, i1, s2, 32);
237 check (res, le);
238 fn12 (res, i1, l2, 32);
239 check (res, le);
241 fn13 (res, i1, i2, 32);
242 check (res, eq);
243 fn14 (res, i1, s2, 32);
244 check (res, eq);
245 fn15 (res, i1, l2, 32);
246 check (res, eq);
248 fn16 (res, i1, i2, 32);
249 check (res, ne);
250 fn17 (res, i1, s2, 32);
251 check (res, ne);
252 fn18 (res, i1, l2, 32);
253 check (res, ne);
256 /* { dg-final { scan-tree-dump-times "VECTORIZED" 18 "vect" { target sse4_runtime } } } */