1 /* { dg-do compile { target powerpc*-*-* } } */
2 /* { dg-require-effective-target powerpc_altivec_ok } */
3 /* { dg-options "-maltivec" } */
11 /* Endian considerations: The "high" half of a vector with n elements is the
12 first n/2 elements of the vector. For little endian, these elements are in
13 the rightmost half of the vector. For big endian, these elements are in the
14 leftmost half of the vector. */
22 vector
bool short vec_bs_arg
;
23 vector
bool short vec_bs_result
, vec_bs_expected
;
24 vector
bool int vec_bi_arg
;
25 vector
bool int vec_bi_result
, vec_bi_expected
;
26 vector
bool char vec_bc_arg
;
27 vector
bool char vec_bc_result
, vec_bc_expected
;
28 vector
signed short vec_ss_arg
;
29 vector
signed short vec_ss_result
, vec_ss_expected
;
30 vector
signed int vec_si_arg
;
31 vector
signed int vec_si_result
, vec_si_expected
;
32 vector
signed char vec_sc_arg
;
33 vector
signed char vec_sc_result
, vec_sc_expected
;
34 vector pixel vec_pixel_arg
;
35 vector
unsigned int vec_ui_result
, vec_ui_expected
;
37 vec_bs_arg
= (vector
bool short){ 0, 101, 202, 303,
39 vec_bi_expected
= (vector
bool int){ 0, 101, 202, 303 };
41 vec_bi_result
= vec_unpackh (vec_bs_arg
);
43 for (i
= 0; i
< 4; i
++) {
44 if (vec_bi_expected
[i
] != vec_bi_result
[i
])
46 printf("ERROR: vec_unpackh(), vec_bi_expected[%d] = %d does not match vec_bi_result[%d] = %d\n",
47 i
, vec_bi_expected
[i
], i
, vec_bi_result
[i
]);
53 vec_bi_expected
= (vector
bool int){ 404, 505, 606, 707 };
54 vec_bi_result
= vec_unpackl (vec_bs_arg
);
56 for (i
= 0; i
< 4; i
++) {
57 if (vec_bi_expected
[i
] != vec_bi_result
[i
])
59 printf("ERROR: vec_unpackl(), vec_bi_expected[%d] = %d does not match vec_bi_result[%d] = %d\n",
60 i
, vec_bi_expected
[i
], i
, vec_bi_result
[i
]);
67 vec_ss_arg
= (vector
signed short){ 0, 101, 202, 303,
69 vec_si_expected
= (vector
signed int){ 0, 101, 202, 303 };
71 vec_si_result
= vec_unpackh (vec_ss_arg
);
73 for (i
= 0; i
< 4; i
++) {
74 if (vec_si_expected
[i
] != vec_si_result
[i
])
76 printf("ERROR: vec_unpackh(), vec_si_expected[%d] = %d does not match vec_si_result[%d] = %d\n",
77 i
, vec_si_expected
[i
], i
, vec_si_result
[i
]);
83 vec_si_expected
= (vector
signed int){ 404, 505, 606, 707 };
85 vec_si_result
= vec_unpackl (vec_ss_arg
);
87 for (i
= 0; i
< 4; i
++) {
88 if (vec_si_expected
[i
] != vec_si_result
[i
])
90 printf("ERROR: vec_unpackl(), vec_si_expected[%d] = %d does not match vec_si_result[%d] = %d\n",
91 i
, vec_si_expected
[i
], i
, vec_si_result
[i
]);
98 vec_pixel_arg
= (vector pixel
){ 0x0, 0x65, 0xca, 0x12f,
99 0x194, 0x1f9, 0x25e, 0x2c3 };
100 vec_ui_expected
= (vector
unsigned int){ 0x0, 0x305, 0x60a, 0x90f };
102 vec_ui_result
= vec_unpackh (vec_pixel_arg
);
104 for (i
= 0; i
< 4; i
++) {
105 if (vec_ui_expected
[i
] != vec_ui_result
[i
])
107 printf("ERROR: vec_unpackh(), vec_ui_expected[%d] = 0x%x does not match vec_ui_result[%d] = 0x%x\n",
108 i
, vec_ui_expected
[i
], i
, vec_ui_result
[i
]);
114 vec_ui_expected
= (vector
unsigned int){ 0xc14, 0xf19, 0x121e, 0x1603 };
116 vec_ui_result
= vec_unpackl (vec_pixel_arg
);
118 for (i
= 0; i
< 4; i
++) {
119 if (vec_ui_expected
[i
] != vec_ui_result
[i
])
121 printf("ERROR: vec_unpackl(), vec_ui_expected[%d] = 0x%x does not match vec_ui_result[%d] = 0x%x\n",
122 i
, vec_ui_expected
[i
], i
, vec_ui_result
[i
]);
129 vec_bc_arg
= (vector
bool char){ 0, 1, 0, 1, 0, 1, 0, 1,
130 0, 0, 1, 1, 0, 0, 1, 1 };
132 vec_bs_expected
= (vector
bool short){ 0, 1, 0, 1, 0, 1, 0, 1 };
134 vec_bs_result
= vec_unpackh (vec_bc_arg
);
136 for (i
= 0; i
< 8; i
++) {
137 if (vec_bs_expected
[i
] != vec_bs_result
[i
])
139 printf("ERROR: vec_unpackh(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n",
140 i
, vec_bs_expected
[i
], i
, vec_bs_result
[i
]);
146 vec_bs_expected
= (vector
bool short){ 0, 0, 1, 1, 0, 0, 1, 1 };
148 vec_bs_result
= vec_unpackl (vec_bc_arg
);
150 for (i
= 0; i
< 8; i
++) {
151 if (vec_bs_expected
[i
] != vec_bs_result
[i
])
153 printf("ERROR: vec_unpackh(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n",
154 i
, vec_bs_expected
[i
], i
, vec_bs_result
[i
]);
160 vec_bs_expected
= (vector
bool short){ 0, 0, 1, 1, 0, 0, 1, 1 };
162 vec_bs_result
= vec_unpackl (vec_bc_arg
);
164 for (i
= 0; i
< 8; i
++) {
165 if (vec_bs_expected
[i
] != vec_bs_result
[i
])
167 printf("ERROR: vec_unpackl(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n",
168 i
, vec_bs_expected
[i
], i
, vec_bs_result
[i
]);
175 vec_sc_arg
= (vector
signed char){ 0, 1, 2, 3, 4, 5, 6, 7,
176 8, 9, 10, 11, 12, 13, 14, 15 };
178 vec_ss_expected
= (vector
signed short){ 0, 1, 2, 3, 4, 5, 6, 7 };
180 vec_ss_result
= vec_unpackh (vec_sc_arg
);
182 for (i
= 0; i
< 8; i
++) {
183 if (vec_ss_expected
[i
] != vec_ss_result
[i
])
185 printf("ERROR: vec_unpackh(), vec_ss_expected[%d] = %d does not match vec_ss_result[%d] = %d\n",
186 i
, vec_ss_expected
[i
], i
, vec_ss_result
[i
]);
192 vec_ss_expected
= (vector
signed short){ 8, 9, 10, 11, 12, 13, 14, 15 };
194 vec_ss_result
= vec_unpackl (vec_sc_arg
);
196 for (i
= 0; i
< 8; i
++) {
197 if (vec_ss_expected
[i
] != vec_ss_result
[i
])
199 printf("ERROR: vec_unpackl(), vec_ss_expected[%d] = %d does not match vec_ss_result[%d] = %d\n",
200 i
, vec_ss_expected
[i
], i
, vec_ss_result
[i
]);