[testsuite]
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtins-3.c
blobb8a6dcdbb334b817613ac7bb4ea3a5981165e59a
1 /* { dg-do compile } */
2 /* { dg-require-effective-target powerpc_vsx_ok } */
3 /* { dg-options "-O2 -mvsx -mcpu=power6" } */
4 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */
6 #include <altivec.h>
8 vector bool char
9 test_eq_char (vector bool char x, vector bool char y)
11 return vec_cmpeq (x, y);
14 vector bool short
15 test_eq_short (vector bool short x, vector bool short y)
17 return vec_cmpeq (x, y);
20 vector bool int
21 test_eq_int (vector bool int x, vector bool int y)
23 return vec_cmpeq (x, y);
26 vector double
27 test_shift_left_double (vector double x, vector double y)
29 return vec_sld (x, y, /* shift_by */ 10);
32 vector signed char
33 test_nabs_char (vector signed char x)
35 return vec_nabs (x);
38 vector short
39 test_nabs_short (vector short x)
41 return vec_nabs (x);
44 vector int
45 test_nabs_int (vector int x)
47 return vec_nabs (x);
50 vector float
51 test_nabs_float (vector float x)
53 return vec_nabs (x);
56 vector double
57 test_nabs_double (vector double x)
59 return vec_nabs (x);
62 vector signed char
63 test_neg_char (vector signed char x)
65 return vec_neg (x);
68 vector short
69 test_neg_short (vector short x)
71 return vec_neg (x);
74 vector int
75 test_neg_int (vector int x)
77 return vec_neg (x);
80 vector float
81 test_neg_float (vector float x)
83 return vec_neg (x);
86 vector double
87 test_neg_double (vector double x)
89 return vec_neg (x);
92 vector signed char
93 test_sll_vsc_vsc_vsuc (vector signed char x, vector unsigned char y)
95 return vec_sll (x, y);
98 vector unsigned char
99 test_sll_vuc_vuc_vuc (vector unsigned char x, vector unsigned char y)
101 return vec_sll (x, y);
104 vector signed int
105 test_sll_vsi_vsi_vuc (vector signed int x, vector unsigned char y)
107 return vec_sll (x, y);
110 vector unsigned int
111 test_sll_vui_vui_vuc (vector unsigned int x, vector unsigned char y)
113 return vec_sll (x, y);
116 vector bool long long
117 test_sll_vbll_vbll_vuc (vector bool long long x,
118 vector unsigned char y)
120 return vec_sll (x, y);
123 vector bool long long
124 test_sll_vbll_vbll_vull (vector bool long long x,
125 vector unsigned long long y)
127 return vec_sll (x, y);
130 vector bool long long
131 test_sll_vbll_vbll_vus (vector bool long long x,
132 vector unsigned short y)
134 return vec_sll (x, y);
136 vector pixel
137 test_sll_vp_vp_vuc (vector pixel x, vector unsigned char y)
139 return vec_sll (x, y);
142 vector signed short int
143 test_sll_vssi_vssi_vuc (vector signed short x, vector unsigned char y)
145 return vec_sll (x, y);
148 vector unsigned short int
149 test_sll_vusi_vusi_vuc (vector unsigned short x, vector unsigned char y)
151 return vec_sll (x, y);
154 vector signed char
155 test_slo_vsc_vsc_vsc (vector signed char x, vector signed char y)
157 return vec_slo (x, y);
160 vector signed char
161 test_slo_vsc_vsc_vuc (vector signed char x, vector unsigned char y)
163 return vec_slo (x, y);
166 vector unsigned char
167 test_slo_vuc_vuc_vsc (vector unsigned char x, vector signed char y)
169 return vec_slo (x, y);
172 vector unsigned char
173 test_slo_vuc_vuc_vuc (vector unsigned char x, vector unsigned char y)
175 return vec_slo (x, y);
178 vector signed int
179 test_slo_vsi_vsi_vsc (vector signed int x, vector signed char y)
181 return vec_slo (x, y);
184 vector signed int
185 test_slo_vsi_vsi_vuc (vector signed int x, vector unsigned char y)
187 return vec_slo (x, y);
190 vector unsigned int
191 test_slo_vui_vui_vsc (vector unsigned int x, vector signed char y)
193 return vec_slo (x, y);
196 vector unsigned int
197 test_slo_vui_vui_vuc (vector unsigned int x, vector unsigned char y)
199 return vec_slo (x, y);
202 vector signed long long
203 test_slo_vsll_slo_vsll_vsc (vector signed long long x, vector signed char y)
205 return vec_slo (x, y);
208 vector signed long long
209 test_slo_vsll_slo_vsll_vuc (vector signed long long x, vector unsigned char y)
211 return vec_slo (x, y);
214 vector unsigned long long
215 test_slo_vull_slo_vull_vsc (vector unsigned long long x, vector signed char y)
217 return vec_slo (x, y);
220 vector unsigned long long
221 test_slo_vull_slo_vull_vuc (vector unsigned long long x,
222 vector unsigned char y)
224 return vec_slo (x, y);
227 vector pixel
228 test_slo_vp_vp_vsc (vector pixel int x, vector signed char y)
230 return vec_slo (x, y);
233 vector pixel
234 test_slo_vp_vp_vuc (vector pixel int x, vector unsigned char y)
236 return vec_slo (x, y);
239 vector signed short int
240 test_slo_vssi_vssi_vsc (vector signed short int x, vector signed char y)
242 return vec_slo (x, y);
245 vector signed short int
246 test_slo_vssi_vssi_vuc (vector signed short int x, vector unsigned char y)
248 return vec_slo (x, y);
251 vector unsigned short int
252 test_slo_vusi_vusi_vsc (vector unsigned short int x, vector signed char y)
254 return vec_slo (x, y);
257 vector unsigned short int
258 test_slo_vusi_vusi_vuc (vector unsigned short int x, vector unsigned char y)
260 return vec_slo (x, y);
263 vector float
264 test_slo_vf_vf_vsc (vector float x, vector signed char y)
266 return vec_slo (x, y);
269 vector float
270 test_slo_vf_vf_vuc (vector float x, vector unsigned char y)
272 return vec_slo (x, y);
275 vector signed char
276 test_vsc_sldw_vsc_vsc (vector signed char x, vector signed char y)
278 return vec_sldw (x, y, 1);
281 vector unsigned char
282 test_vuc_sldw_vuc_vuc (vector unsigned char x, vector unsigned char y)
284 return vec_sldw (x, y, 3);
287 vector signed short int
288 test_vssi_sldw_vssi_vssi (vector signed short int x,
289 vector signed short int y)
291 return vec_sldw (x, y, 1);
294 vector unsigned short int
295 test_vusi_sldw_vusi_vusi (vector unsigned short int x,
296 vector unsigned short int y)
298 return vec_sldw (x, y, 3);
301 vector signed int
302 test_vsi_sldw_vsi_vsi (vector signed int x, vector signed int y)
304 return vec_sldw (x, y, 1);
307 vector unsigned int
308 test_vui_sldw_vui_vui (vector unsigned int x, vector unsigned int y)
310 return vec_sldw (x, y, 3);
313 vector signed long long
314 test_vsl_sldw_vsl_vsl (vector signed long long x, vector signed long long y)
316 return vec_sldw (x, y, 1);
319 vector unsigned long long
320 test_vul_sldw_vul_vul (vector unsigned long long x,
321 vector unsigned long long y)
323 return vec_sldw (x, y, 3);
326 vector int
327 test_cmpb_float (vector float x, vector float y)
329 return vec_cmpb (x, y);
332 /* Expected test results:
334 test_eq_char 1 vcmpequb inst
335 test_eq_short 1 vcmpequh inst
336 test_eq_int 1 vcmpequw inst
337 test_shift_left_double 1 vsldoi inst
338 test_nabs_char 1 vspltisw, 1 vsububm, 1 vminsb
339 test_nabs_short 1 vspltisw, 1 vsubuhm, 1 vminsh
340 test_nabs_int 1 vspltisw, 1 vsubuwm, 1 vminsw
341 test_nabs_float 1 xvnabssp
342 test_nabs_double 1 xvnabsdp
343 test_neg_char 1 vspltisw, 1 vsububm
344 test_neg_short 1 vspltisw, 1 vsubuhm
345 test_neg_int 1 vspltisw, 1 vsubuwm
346 test_neg_float 1 xvnegsp
347 test_neg_float 1 xvnegdp
348 test_vsll_slo_vsll_vsc 1 vslo
349 test_vsll_slo_vsll_vuc 1 vslo
350 test_vull_slo_vsll_vsc 1 vslo
351 test_vull_slo_vsll_vuc 1 vslo
352 test_vsc_mulo_vsc_vsc 1 xxsldwi
353 test_vuc_mulo_vuc_vuc 1 xxsldwi
354 test_vssi_mulo_vssi_vssi 1 xxsldwi
355 test_vusi_mulo_vusi_vusi 1 xxsldwi
356 test_vsi_mulo_vsi_vsi 1 xxsldwi
357 test_vui_mulo_vui_vui 1 xxsldwi
358 test_vsl_mulo_vsl_vsl 1 xxsldwi
359 test_vul_mulo_vul_vul 1 xxsldwi
360 test_cmpb_float 1 vcmpbfp */
362 /* { dg-final { scan-assembler-times "vcmpequb" 1 } } */
363 /* { dg-final { scan-assembler-times "vcmpequh" 1 } } */
364 /* { dg-final { scan-assembler-times "vcmpequw" 1 } } */
365 /* { dg-final { scan-assembler-times "vsldoi" 1 } } */
366 /* { dg-final { scan-assembler-times "vsububm" 2 } } */
367 /* { dg-final { scan-assembler-times "vsubuhm" 2 } } */
368 /* { dg-final { scan-assembler-times "vsubuwm" 2 } } */
369 /* { dg-final { scan-assembler-times "vminsb" 1 } } */
370 /* { dg-final { scan-assembler-times "vminsh" 1 } } */
371 /* { dg-final { scan-assembler-times "vminsw" 1 } } */
372 /* { dg-final { scan-assembler-times "vspltisw" 6 } } */
373 /* { dg-final { scan-assembler-times "xvnabssp" 1 } } */
374 /* { dg-final { scan-assembler-times "xvnabsdp" 1 } } */
375 /* { dg-final { scan-assembler-times "xvnegsp" 1 } } */
376 /* { dg-final { scan-assembler-times "xvnegdp" 1 } } */
377 /* { dg-final { scan-assembler-times "vslo" 20 } } */
378 /* { dg-final { scan-assembler-times "xxsldwi" 8 } } */
379 /* { dg-final { scan-assembler-times "vcmpbfp" 1 } } */