Dead
[official-gcc.git] / gomp-20050608-branch / gcc / testsuite / gcc.target / powerpc / altivec-consts.c
blob318c723bcf5a5aa1de84868a4d47f598179a5e34
1 /* { dg-do run { target powerpc*-*-* } } */
2 /* { dg-xfail-if "" { "powerpc-*-eabispe*" "powerpc-ibm-aix*" } { "*" } { "" } } */
3 /* { dg-options "-maltivec -mabi=altivec -O2" } */
5 /* Check that "easy" AltiVec constants are correctly synthesized. */
7 #include "altivec_check.h"
9 extern void abort (void);
11 typedef __attribute__ ((vector_size (16))) unsigned char v16qi;
12 typedef __attribute__ ((vector_size (16))) unsigned short v8hi;
13 typedef __attribute__ ((vector_size (16))) unsigned int v4si;
15 char w[16] __attribute__((aligned(16)));
18 /* Emulate the vspltis? instructions on a 16-byte array of chars. */
20 void vspltisb (char *v, int val)
22 int i;
23 for (i = 0; i < 16; i++)
24 v[i] = val;
27 void vspltish (char *v, int val)
29 int i;
30 for (i = 0; i < 16; i += 2)
31 v[i] = val >> 7, v[i + 1] = val;
34 void vspltisw (char *v, int val)
36 int i;
37 for (i = 0; i < 16; i += 4)
38 v[i] = v[i + 1] = v[i + 2] = val >> 7, v[i + 3] = val;
42 /* Use three different check functions for each mode-instruction pair.
43 The callers have no typecasting and no addressable vectors, to make
44 the test more robust. */
46 void __attribute__ ((noinline)) check_v16qi (v16qi v1, char *v2)
48 if (memcmp (&v1, v2, 16))
49 abort ();
52 void __attribute__ ((noinline)) check_v8hi (v8hi v1, char *v2)
54 if (memcmp (&v1, v2, 16))
55 abort ();
58 void __attribute__ ((noinline)) check_v4si (v4si v1, char *v2)
60 if (memcmp (&v1, v2, 16))
61 abort ();
65 /* V16QI tests. */
67 void v16qi_vspltisb ()
69 v16qi v = { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 };
70 vspltisb (w, 15);
71 check_v16qi (v, w);
74 void v16qi_vspltisb_neg ()
76 v16qi v = { -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5 };
77 vspltisb (w, -5);
78 check_v16qi (v, w);
81 void v16qi_vspltisb_addself ()
83 v16qi v = { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 };
84 vspltisb (w, 30);
85 check_v16qi (v, w);
88 void v16qi_vspltisb_neg_addself ()
90 v16qi v = { -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24 };
91 vspltisb (w, -24);
92 check_v16qi (v, w);
95 void v16qi_vspltish ()
97 v16qi v = { 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15 };
98 vspltish (w, 15);
99 check_v16qi (v, w);
102 void v16qi_vspltish_addself ()
104 v16qi v = { 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30 };
105 vspltish (w, 30);
106 check_v16qi (v, w);
109 void v16qi_vspltish_neg ()
111 v16qi v = { -1, -5, -1, -5, -1, -5, -1, -5, -1, -5, -1, -5, -1, -5, -1, -5 };
112 vspltish (w, -5);
113 check_v16qi (v, w);
116 void v16qi_vspltisw ()
118 v16qi v = { 0, 0, 0, 15, 0, 0, 0, 15, 0, 0, 0, 15, 0, 0, 0, 15 };
119 vspltisw (w, 15);
120 check_v16qi (v, w);
123 void v16qi_vspltisw_addself ()
125 v16qi v = { 0, 0, 0, 30, 0, 0, 0, 30, 0, 0, 0, 30, 0, 0, 0, 30 };
126 vspltisw (w, 30);
127 check_v16qi (v, w);
130 void v16qi_vspltisw_neg ()
132 v16qi v = { -1, -1, -1, -5, -1, -1, -1, -5, -1, -1, -1, -5, -1, -1, -1, -5 };
133 vspltisw (w, -5);
134 check_v16qi (v, w);
138 /* V8HI tests. */
140 void v8hi_vspltisb ()
142 v8hi v = { 0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F, 0x0F0F };
143 vspltisb (w, 15);
144 check_v8hi (v, w);
147 void v8hi_vspltisb_addself ()
149 v8hi v = { 0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E, 0x1E1E };
150 vspltisb (w, 30);
151 check_v8hi (v, w);
154 void v8hi_vspltisb_neg ()
156 v8hi v = { 0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB, 0xFBFB };
157 vspltisb (w, -5);
158 check_v8hi (v, w);
161 void v8hi_vspltish ()
163 v8hi v = { 15, 15, 15, 15, 15, 15, 15, 15 };
164 vspltish (w, 15);
165 check_v8hi (v, w);
168 void v8hi_vspltish_neg ()
170 v8hi v = { -5, -5, -5, -5, -5, -5, -5, -5 };
171 vspltish (w, -5);
172 check_v8hi (v, w);
175 void v8hi_vspltish_addself ()
177 v8hi v = { 30, 30, 30, 30, 30, 30, 30, 30 };
178 vspltish (w, 30);
179 check_v8hi (v, w);
182 void v8hi_vspltish_neg_addself ()
184 v8hi v = { -24, -24, -24, -24, -24, -24, -24, -24 };
185 vspltish (w, -24);
186 check_v8hi (v, w);
189 void v8hi_vspltisw ()
191 v8hi v = { 0, 15, 0, 15, 0, 15, 0, 15 };
192 vspltisw (w, 15);
193 check_v8hi (v, w);
196 void v8hi_vspltisw_addself ()
198 v8hi v = { 0, 30, 0, 30, 0, 30, 0, 30 };
199 vspltisw (w, 30);
200 check_v8hi (v, w);
203 void v8hi_vspltisw_neg ()
205 v8hi v = { -1, -5, -1, -5, -1, -5, -1, -5 };
206 vspltisw (w, -5);
207 check_v8hi (v, w);
210 /* V4SI tests. */
212 void v4si_vspltisb ()
214 v4si v = { 0x0F0F0F0F, 0x0F0F0F0F, 0x0F0F0F0F, 0x0F0F0F0F };
215 vspltisb (w, 15);
216 check_v4si (v, w);
219 void v4si_vspltisb_addself ()
221 v4si v = { 0x1E1E1E1E, 0x1E1E1E1E, 0x1E1E1E1E, 0x1E1E1E1E };
222 vspltisb (w, 30);
223 check_v4si (v, w);
226 void v4si_vspltisb_neg ()
228 v4si v = { 0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB };
229 vspltisb (w, -5);
230 check_v4si (v, w);
233 void v4si_vspltish ()
235 v4si v = { 0x000F000F, 0x000F000F, 0x000F000F, 0x000F000F };
236 vspltish (w, 15);
237 check_v4si (v, w);
240 void v4si_vspltish_addself ()
242 v4si v = { 0x001E001E, 0x001E001E, 0x001E001E, 0x001E001E };
243 vspltish (w, 30);
244 check_v4si (v, w);
247 void v4si_vspltish_neg ()
249 v4si v = { 0xFFFBFFFB, 0xFFFBFFFB, 0xFFFBFFFB, 0xFFFBFFFB };
250 vspltish (w, -5);
251 check_v4si (v, w);
254 void v4si_vspltisw ()
256 v4si v = { 15, 15, 15, 15 };
257 vspltisw (w, 15);
258 check_v4si (v, w);
261 void v4si_vspltisw_neg ()
263 v4si v = { -5, -5, -5, -5 };
264 vspltisw (w, -5);
265 check_v4si (v, w);
268 void v4si_vspltisw_addself ()
270 v4si v = { 30, 30, 30, 30 };
271 vspltisw (w, 30);
272 check_v4si (v, w);
275 void v4si_vspltisw_neg_addself ()
277 v4si v = { -24, -24, -24, -24 };
278 vspltisw (w, -24);
279 check_v4si (v, w);
284 int main ()
286 altivec_check (); /* Exit if hardware doesn't support AltiVec. */
288 v16qi_vspltisb ();
289 v16qi_vspltisb_neg ();
290 v16qi_vspltisb_addself ();
291 v16qi_vspltisb_neg_addself ();
292 v16qi_vspltish ();
293 v16qi_vspltish_addself ();
294 v16qi_vspltish_neg ();
295 v16qi_vspltisw ();
296 v16qi_vspltisw_addself ();
297 v16qi_vspltisw_neg ();
299 v8hi_vspltisb ();
300 v8hi_vspltisb_addself ();
301 v8hi_vspltisb_neg ();
302 v8hi_vspltish ();
303 v8hi_vspltish_neg ();
304 v8hi_vspltish_addself ();
305 v8hi_vspltish_neg_addself ();
306 v8hi_vspltisw ();
307 v8hi_vspltisw_addself ();
308 v8hi_vspltisw_neg ();
310 v4si_vspltisb ();
311 v4si_vspltisb_addself ();
312 v4si_vspltisb_neg ();
313 v4si_vspltish ();
314 v4si_vspltish_addself ();
315 v4si_vspltish_neg ();
316 v4si_vspltisw ();
317 v4si_vspltisw_neg ();
318 v4si_vspltisw_addself ();
319 v4si_vspltisw_neg_addself ();
320 return 0;