Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/vec-perm-ctor-run.c

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-O2 -mvsx" } */
4
5 #include "vec-perm-ctor.h"
6
7 #include <stdlib.h>
8
9 int
10 main ()
11 {
12 du a_du = 100ULL;
13 du b_du = 200ULL;
14
15 di a_di = -100;
16 di b_di = 200;
17
18 df a_df = 10.0;
19 df b_df = 20.0;
20
21 si a_si = 12;
22 si b_si = -25;
23 si c_si = -37;
24 si d_si = 50;
25
26 sf a_sf = 30.0f;
27 sf b_sf = 40.0f;
28 sf c_sf = 50.0f;
29 sf d_sf = 60.0f;
30
31 hu a_hu = 10;
32 hu b_hu = 20;
33 hu c_hu = 30;
34 hu d_hu = 40;
35 hu e_hu = 50;
36 hu f_hu = 60;
37 hu g_hu = 70;
38 hu h_hu = 80;
39
40 qi a_qi = 10;
41 qi b_qi = 20;
42 qi c_qi = -30;
43 qi d_qi = 40;
44 qi e_qi = -50;
45 qi f_qi = 60;
46 qi g_qi = 70;
47 qi h_qi = -80;
48
49 v2du res1 = test_ctor_ctor_same_du (a_du, b_du);
50 if (res1[0] != a_du || res1[1] != b_du)
51 abort ();
52
53 v2df res2 = test_ctor_ctor_same_df (a_df, b_df);
54 if (res2[0] != a_df || res2[1] != b_df)
55 abort ();
56
57 v4si res3 = test_ctor_ctor_same_si (a_si, b_si, c_si, d_si);
58 if (res3[0] != a_si || res3[1] != b_si || res3[2] != c_si || res3[3] != d_si)
59 abort ();
60
61 v4sf res4 = test_ctor_ctor_same_sf (a_sf, b_sf, c_sf, d_sf);
62 if (res4[0] != a_sf || res4[1] != b_sf || res4[2] != c_sf || res4[3] != d_sf)
63 abort ();
64
65 v8hu res5
66 = test_ctor_ctor_same_hu (a_hu, b_hu, c_hu, d_hu, e_hu, f_hu, g_hu, h_hu);
67
68 if (res5[0] != a_hu || res5[1] != b_hu || res5[2] != c_hu || res5[3] != d_hu
69 || res5[4] != e_hu || res5[5] != f_hu || res5[6] != g_hu
70 || res5[7] != h_hu)
71 abort ();
72
73 v16qi res6
74 = test_ctor_ctor_same_qi (a_qi, b_qi, c_qi, d_qi, e_qi, f_qi, g_qi, h_qi);
75
76 if (res6[0] != a_qi || res6[1] != b_qi || res6[2] != c_qi || res6[3] != d_qi
77 || res6[4] != a_qi || res6[5] != b_qi || res6[6] != c_qi
78 || res6[7] != d_qi || res6[8] != e_qi || res6[9] != f_qi
79 || res6[10] != g_qi || res6[11] != h_qi || res6[12] != e_qi
80 || res6[13] != f_qi || res6[14] != g_qi || res6[15] != h_qi)
81 abort ();
82
83 v2du res7 = test_ctor_cst_same_du (a_du, b_du);
84 if (res7[0] != a_du || res7[1] != 100)
85 abort ();
86
87 v4sf res8 = test_ctor_cst_same_sf (a_sf, b_sf);
88 if (res8[0] != a_sf || res8[1] != 2.0f || res8[2] != b_sf || res8[3] != 4.0f)
89 abort ();
90
91 v2df res9 = test_ctor_cst_same_df (a_df, b_df);
92 if (res9[0] != b_df || res9[1] != 200.0)
93 abort ();
94
95 v4si res10 = test_cst_ctor_same_si (a_si, b_si);
96 if (res10[0] != 1 || res10[1] != 3 || res10[2] != a_si || res10[3] != b_si)
97 abort ();
98
99 v2di res11 = test_ctor_cst_diff_di_si (a_di, b_di);
100 /* Need to take care of the endianness since the function converts vector
101 const to one different vector type (element size), the endianness
102 determines the reinterpreted layout. Same reason for res12 below. */
103 if (res11[0] != -100 ||
104 #ifdef __LITTLE_ENDIAN__
105 res11[1] != 3
106 #else
107 res11[1] != 0x300000000LL
108 #endif
109 )
110 abort ();
111
112 v2du res12 = test_cst_ctor_diff_sf_du (a_du, b_du);
113 if (
114 #ifdef __LITTLE_ENDIAN__
115 res12[0] != 0x400000003f800000ULL
116 #else
117 res12[0] != 0x3f80000040000000ULL
118 #endif
119 || res12[1] != 100)
120 abort ();
121
122 return 0;
123 }
124