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
float vec_float_arg
;
35 vector
double vec_double_result
, vec_double_expected
;
36 vector pixel vec_pixel_arg
;
37 vector
unsigned int vec_ui_result
, vec_ui_expected
;
44 vec_bs_arg
= (vector
bool short){ 0, 101, 202, 303,
46 vec_bi_expected
= (vector
bool int){ 0, 101, 202, 303 };
48 vec_bi_result
= vec_unpackh (vec_bs_arg
);
50 for (i
= 0; i
< 4; i
++) {
51 if (vec_bi_expected
[i
] != vec_bi_result
[i
])
53 printf("ERROR: vec_unpackh(), vec_bi_expected[%d] = %d does not match vec_bi_result[%d] = %d\n",
54 i
, vec_bi_expected
[i
], i
, vec_bi_result
[i
]);
60 vec_bi_expected
= (vector
bool int){ 404, 505, 606, 707 };
61 vec_bi_result
= vec_unpackl (vec_bs_arg
);
63 for (i
= 0; i
< 4; i
++) {
64 if (vec_bi_expected
[i
] != vec_bi_result
[i
])
66 printf("ERROR: vec_unpackl(), vec_bi_expected[%d] = %d does not match vec_bi_result[%d] = %d\n",
67 i
, vec_bi_expected
[i
], i
, vec_bi_result
[i
]);
74 vec_ss_arg
= (vector
signed short){ 0, 101, 202, 303,
76 vec_si_expected
= (vector
signed int){ 0, 101, 202, 303 };
78 vec_si_result
= vec_unpackh (vec_ss_arg
);
80 for (i
= 0; i
< 4; i
++) {
81 if (vec_si_expected
[i
] != vec_si_result
[i
])
83 printf("ERROR: vec_unpackh(), vec_si_expected[%d] = %d does not match vec_si_result[%d] = %d\n",
84 i
, vec_si_expected
[i
], i
, vec_si_result
[i
]);
90 vec_si_expected
= (vector
signed int){ 404, 505, 606, 707 };
92 vec_si_result
= vec_unpackl (vec_ss_arg
);
94 for (i
= 0; i
< 4; i
++) {
95 if (vec_si_expected
[i
] != vec_si_result
[i
])
97 printf("ERROR: vec_unpackl(), vec_si_expected[%d] = %d does not match vec_si_result[%d] = %d\n",
98 i
, vec_si_expected
[i
], i
, vec_si_result
[i
]);
105 vec_pixel_arg
= (vector pixel
){ 0x0, 0x65, 0xca, 0x12f,
106 0x194, 0x1f9, 0x25e, 0x2c3 };
107 vec_ui_expected
= (vector
unsigned int){ 0x0, 0x305, 0x60a, 0x90f };
109 vec_ui_result
= vec_unpackh (vec_pixel_arg
);
111 for (i
= 0; i
< 4; i
++) {
112 if (vec_ui_expected
[i
] != vec_ui_result
[i
])
114 printf("ERROR: vec_unpackh(), vec_ui_expected[%d] = 0x%x does not match vec_ui_result[%d] = 0x%x\n",
115 i
, vec_ui_expected
[i
], i
, vec_ui_result
[i
]);
121 vec_ui_expected
= (vector
unsigned int){ 0xc14, 0xf19, 0x121e, 0x1603 };
123 vec_ui_result
= vec_unpackl (vec_pixel_arg
);
125 for (i
= 0; i
< 4; i
++) {
126 if (vec_ui_expected
[i
] != vec_ui_result
[i
])
128 printf("ERROR: vec_unpackl(), vec_ui_expected[%d] = 0x%x does not match vec_ui_result[%d] = 0x%x\n",
129 i
, vec_ui_expected
[i
], i
, vec_ui_result
[i
]);
136 vec_bc_arg
= (vector
bool char){ 0, 1, 0, 1, 0, 1, 0, 1,
137 0, 0, 1, 1, 0, 0, 1, 1 };
139 vec_bs_expected
= (vector
bool short){ 0, 1, 0, 1, 0, 1, 0, 1 };
141 vec_bs_result
= vec_unpackh (vec_bc_arg
);
143 for (i
= 0; i
< 8; i
++) {
144 if (vec_bs_expected
[i
] != vec_bs_result
[i
])
146 printf("ERROR: vec_unpackh(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n",
147 i
, vec_bs_expected
[i
], i
, vec_bs_result
[i
]);
153 vec_bs_expected
= (vector
bool short){ 0, 0, 1, 1, 0, 0, 1, 1 };
155 vec_bs_result
= vec_unpackl (vec_bc_arg
);
157 for (i
= 0; i
< 8; i
++) {
158 if (vec_bs_expected
[i
] != vec_bs_result
[i
])
160 printf("ERROR: vec_unpackh(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n",
161 i
, vec_bs_expected
[i
], i
, vec_bs_result
[i
]);
167 vec_bs_expected
= (vector
bool short){ 0, 0, 1, 1, 0, 0, 1, 1 };
169 vec_bs_result
= vec_unpackl (vec_bc_arg
);
171 for (i
= 0; i
< 8; i
++) {
172 if (vec_bs_expected
[i
] != vec_bs_result
[i
])
174 printf("ERROR: vec_unpackl(), vec_bs_expected[%d] = %d does not match vec_bs_result[%d] = %d\n",
175 i
, vec_bs_expected
[i
], i
, vec_bs_result
[i
]);
182 vec_sc_arg
= (vector
signed char){ 0, 1, 2, 3, 4, 5, 6, 7,
183 8, 9, 10, 11, 12, 13, 14, 15 };
185 vec_ss_expected
= (vector
signed short){ 0, 1, 2, 3, 4, 5, 6, 7 };
187 vec_ss_result
= vec_unpackh (vec_sc_arg
);
189 for (i
= 0; i
< 8; i
++) {
190 if (vec_ss_expected
[i
] != vec_ss_result
[i
])
192 printf("ERROR: vec_unpackh(), vec_ss_expected[%d] = %d does not match vec_ss_result[%d] = %d\n",
193 i
, vec_ss_expected
[i
], i
, vec_ss_result
[i
]);
199 vec_ss_expected
= (vector
signed short){ 8, 9, 10, 11, 12, 13, 14, 15 };
201 vec_ss_result
= vec_unpackl (vec_sc_arg
);
203 for (i
= 0; i
< 8; i
++) {
204 if (vec_ss_expected
[i
] != vec_ss_result
[i
])
206 printf("ERROR: vec_unpackl(), vec_ss_expected[%d] = %d does not match vec_ss_result[%d] = %d\n",
207 i
, vec_ss_expected
[i
], i
, vec_ss_result
[i
]);
214 vec_float_arg
= (vector
float){ 0.0, 1.5, 2.5, 3.5 };
216 vec_double_expected
= (vector
double){ 0.0, 1.5 };
218 vec_double_result
= vec_unpackh (vec_float_arg
);
220 for (i
= 0; i
< 2; i
++) {
221 if (vec_double_expected
[i
] != vec_double_result
[i
])
224 printf("ERROR: vec_unpackh(), vec_double_expected[%d] = %f does not match vec_double_result[%d] = %f\n",
225 i
, vec_double_expected
[i
], i
, vec_double_result
[i
]);
226 conv_val
.d
= vec_double_result
[i
];
227 conv_exp
.d
= vec_double_expected
[i
];
228 printf(" vec_unpackh(), vec_double_expected[%d] = 0x%llx does not match vec_double_result[%d] = 0x%llx\n",
229 i
, conv_exp
.l
, i
,conv_val
.l
);
236 vec_double_expected
= (vector
double){ 2.5, 3.5 };
238 vec_double_result
= vec_unpackl (vec_float_arg
);
240 for (i
= 0; i
< 2; i
++) {
241 if (vec_double_expected
[i
] != vec_double_result
[i
])
244 printf("ERROR: vec_unpackl() vec_double_expected[%d] = %f does not match vec_double_result[%d] = %f\n",
245 i
, vec_double_expected
[i
], i
, vec_double_result
[i
]);
246 conv_val
.d
= vec_double_result
[i
];
247 conv_exp
.d
= vec_double_expected
[i
];
248 printf(" vec_unpackh(), vec_double_expected[%d] = 0x%llx does not match vec_double_result[%d] = 0x%llx\n",
249 i
, conv_exp
.l
, i
,conv_val
.l
);