PR tree-optimization/84740
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-cond-10.c
blob1a18800850a1f2337e359c7852c2702862bd6037
1 /* { dg-require-effective-target vect_cond_mixed } */
2 /* { dg-require-effective-target vect_float } */
3 /* { dg-additional-options "-fno-ipa-icf" } */
5 #include "tree-vect.h"
7 #define N 1024
8 float a[N], b[N], c[N], d[N];
9 _Bool k[N];
11 __attribute__((noinline, noclone)) void
12 f1 (void)
14 int i;
15 for (i = 0; i < N; ++i)
17 int x = a[i] < b[i];
18 int y = c[i] < d[i];
19 k[i] = x & y;
23 __attribute__((noinline, noclone)) void
24 f2 (void)
26 int i;
27 for (i = 0; i < N; ++i)
28 k[i] = (a[i] < b[i]) & (c[i] < d[i]);
31 __attribute__((noinline, noclone)) void
32 f3 (void)
34 int i;
35 for (i = 0; i < N; ++i)
37 int x = a[i] < b[i];
38 int y = c[i] < d[i];
39 k[i] = x | y;
43 __attribute__((noinline, noclone)) void
44 f4 (void)
46 int i;
47 for (i = 0; i < N; ++i)
48 k[i] = (a[i] < b[i]) | (c[i] < d[i]);
51 __attribute__((noinline, noclone)) void
52 f5 (_Bool *p)
54 int i;
55 for (i = 0; i < N; ++i)
57 int x = a[i] < b[i];
58 int y = c[i] < d[i];
59 p[i] = x & y;
63 __attribute__((noinline, noclone)) void
64 f6 (_Bool *p)
66 int i;
67 for (i = 0; i < N; ++i)
68 p[i] = (a[i] < b[i]) & (c[i] < d[i]);
71 __attribute__((noinline, noclone)) void
72 f7 (_Bool *p)
74 int i;
75 for (i = 0; i < N; ++i)
77 int x = a[i] < b[i];
78 int y = c[i] < d[i];
79 p[i] = x | y;
83 __attribute__((noinline, noclone)) void
84 f8 (_Bool *p)
86 int i;
87 for (i = 0; i < N; ++i)
88 p[i] = (a[i] < b[i]) | (c[i] < d[i]);
91 int
92 main ()
94 int i;
96 check_vect ();
98 for (i = 0; i < N; i++)
100 switch (i % 9)
102 case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break;
103 case 1: a[i] = 0; b[i] = 0; break;
104 case 2: a[i] = i + 1; b[i] = - i - 1; break;
105 case 3: a[i] = i; b[i] = i + 7; break;
106 case 4: a[i] = i; b[i] = i; break;
107 case 5: a[i] = i + 16; b[i] = i + 3; break;
108 case 6: a[i] = - i - 5; b[i] = - i; break;
109 case 7: a[i] = - i; b[i] = - i; break;
110 case 8: a[i] = - i; b[i] = - i - 7; break;
113 for (i = 0; i < N; i++)
115 switch ((i / 9) % 3)
117 case 0: c[i] = a[i / 9]; d[i] = b[i / 9]; break;
118 case 1: c[i] = a[i / 9 + 3]; d[i] = b[i / 9 + 3]; break;
119 case 2: c[i] = a[i / 9 + 6]; d[i] = b[i / 9 + 6]; break;
122 f1 ();
123 for (i = 0; i < N; i++)
124 if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
125 abort ();
126 __builtin_memset (k, 0, sizeof (k));
127 f2 ();
128 for (i = 0; i < N; i++)
129 if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
130 abort ();
131 __builtin_memset (k, 0, sizeof (k));
132 f3 ();
133 for (i = 0; i < N; i++)
134 if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
135 abort ();
136 __builtin_memset (k, 0, sizeof (k));
137 f4 ();
138 for (i = 0; i < N; i++)
139 if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
140 abort ();
141 __builtin_memset (k, 0, sizeof (k));
142 f5 (k);
143 for (i = 0; i < N; i++)
144 if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
145 abort ();
146 __builtin_memset (k, 0, sizeof (k));
147 f6 (k);
148 for (i = 0; i < N; i++)
149 if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
150 abort ();
151 __builtin_memset (k, 0, sizeof (k));
152 f7 (k);
153 for (i = 0; i < N; i++)
154 if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
155 abort ();
156 __builtin_memset (k, 0, sizeof (k));
157 f8 (k);
158 for (i = 0; i < N; i++)
159 if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
160 abort ();
161 __builtin_memset (k, 0, sizeof (k));
163 return 0;
166 /* { dg-final { scan-tree-dump-times "note: vectorized 1 loops" 8 "vect" } } */