* gcc.target/powerpc/builtins-1-be.c <vclzb>: Rename duplicate test
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtins-2.c
blob666e96776733a5b1b603c7603b0720e785438057
1 /* { dg-do run { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
3 /* { dg-options "-mcpu=power8 " } */
5 #include <altivec.h>
7 #ifdef DEBUG
8 #include <stdio.h>
9 #endif
11 void abort (void);
13 int main ()
15 vector int inta = {27, -1, 4, 9};
16 vector unsigned int uinta = {9, 0, 7, 222};
18 vector long long sa = {27L, -14L};
19 vector long long sb = {-9L, -2L};
21 vector unsigned long long ua = {27L, 14L};
22 vector unsigned long long ub = {9L, 2L};
24 vector long long sc = vec_div (sa, sb);
25 vector unsigned long long uc = vec_div (ua, ub);
27 if (sc[0] != -3L || sc[1] != 7L || uc[0] != 3L || uc[1] != 7L)
28 abort ();
30 vector long long sd = vec_mul (sa, sb);
31 vector unsigned long long ud = vec_mul (ua, ub);
33 if (sd[0] != -243L || sd[1] != 28L || ud[0] != 243L || ud[1] != 28L)
34 abort ();
36 vector long long se = vec_splat (sa, 0);
37 vector long long sf = vec_splat (sa, 1);
38 vector unsigned long long ue = vec_splat (ua, 0);
39 vector unsigned long long uf = vec_splat (ua, 1);
41 if (se[0] != 27L || se[1] != 27L || sf[0] != -14L || sf[1] != -14L
42 || ue[0] != 27L || ue[1] != 27L || uf[0] != 14L || uf[1] != 14L)
43 abort ();
45 vector double da = vec_ctf (sa, -2);
46 vector double db = vec_ctf (ua, 2);
47 vector long long sg = vec_cts (da, -2);
48 vector unsigned long long ug = vec_ctu (db, 2);
50 if (da[0] != 108.0 || da[1] != -56.0 || db[0] != 6.75 || db[1] != 3.5
51 || sg[0] != 27L || sg[1] != -14L || ug[0] != 27L || ug[1] != 14L)
52 abort ();
54 vector float fa = vec_ctf (inta, 5);
55 if (fa[0] != 0.843750 || fa[1] != -0.031250 || fa[2] != 0.125000 || fa[3] != 0.281250)
56 #ifdef DEBUG
57 printf("fa[0] = %f, fa[1] = %f, fa[2] = %f, fa[3] = %f\n",
58 fa[0], fa[1], fa[2], fa[3]);
59 #else
60 abort ();
61 #endif
63 vector int sa2 = vec_cts (fa, 5);
64 if (sa2[0] != 27 || sa2[1] != -1 || sa2[2] != 4 || sa2[3] != 9)
65 #ifdef DEBUG
66 printf("sa2[0] = %d, sa2[1] = %d, sa2[2] = %d, sa2[3] = %d\n",
67 sa2[0], sa2[1], sa2[2], sa2[3]);
68 #else
69 abort ();
70 #endif
72 vector float fb = vec_ctf (uinta, 2);
74 if (fb[0] != 2.250000 || fb[1] != 0.0 || fb[2] != 1.750000 || fb[3] != 55.500000)
75 #ifdef DEBUG
76 printf("fb[0] = %f, fb[1] = %f, fb[2] = %f, fb[3] = %f\n",
77 fb[0], fb[1], fb[2], fb[3]);
78 #else
79 abort ();
80 #endif
82 vector unsigned int ua2 = vec_ctu (fb, 2);
83 if (ua2[0] != 9 || ua2[1] != 0 || ua2[2] != 7 || ua2[3] != 222)
84 #ifdef DEBUG
85 printf("ua2[0] = %d, ua2[1] = %d, ua2[2] = %d, ua2[3] = %d\n",
86 ua2[0], ua2[1], ua2[2], ua2[3]);
87 #else
88 abort ();
89 #endif
91 return 0;