| 1 |
/* { dg-do run { target { power10_hw } } } */ |
| 2 |
/* { dg-do link { target { ! power10_hw } } } */ |
| 3 |
/* { dg-require-effective-target power10_ok } */ |
| 4 |
/* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */ |
| 5 |
#include <altivec.h> |
| 6 |
|
| 7 |
#define DEBUG 0 |
| 8 |
|
| 9 |
#if DEBUG |
| 10 |
#include <stdio.h> |
| 11 |
#endif |
| 12 |
|
| 13 |
extern void abort (void); |
| 14 |
|
| 15 |
int |
| 16 |
main (int argc, char *argv []) |
| 17 |
{ |
| 18 |
int i; |
| 19 |
|
| 20 |
vector signed char vresult_char; |
| 21 |
vector signed char expected_vresult_char; |
| 22 |
vector signed char src_va_char; |
| 23 |
vector signed char src_vb_char; |
| 24 |
|
| 25 |
vector unsigned char vresult_uchar; |
| 26 |
vector unsigned char expected_vresult_uchar; |
| 27 |
vector unsigned char src_va_uchar; |
| 28 |
vector unsigned char src_vb_uchar; |
| 29 |
|
| 30 |
vector short int vresult_sh; |
| 31 |
vector short int expected_vresult_sh; |
| 32 |
vector short int src_va_sh; |
| 33 |
vector short int src_vb_sh; |
| 34 |
|
| 35 |
vector short unsigned int vresult_ush; |
| 36 |
vector short unsigned int expected_vresult_ush; |
| 37 |
vector short unsigned int src_va_ush; |
| 38 |
vector short unsigned int src_vb_ush; |
| 39 |
|
| 40 |
vector int vresult_int; |
| 41 |
vector int expected_vresult_int; |
| 42 |
vector int src_va_int; |
| 43 |
vector int src_vb_int; |
| 44 |
int src_a_int; |
| 45 |
|
| 46 |
vector unsigned int vresult_uint; |
| 47 |
vector unsigned int expected_vresult_uint; |
| 48 |
vector unsigned int src_va_uint; |
| 49 |
vector unsigned int src_vb_uint; |
| 50 |
unsigned int src_a_uint; |
| 51 |
|
| 52 |
vector long long int vresult_llint; |
| 53 |
vector long long int expected_vresult_llint; |
| 54 |
vector long long int src_va_llint; |
| 55 |
vector long long int src_vb_llint; |
| 56 |
long long int src_a_llint; |
| 57 |
|
| 58 |
vector unsigned long long int vresult_ullint; |
| 59 |
vector unsigned long long int expected_vresult_ullint; |
| 60 |
vector unsigned long long int src_va_ullint; |
| 61 |
vector unsigned long long int src_vb_ullint; |
| 62 |
unsigned int long long src_a_ullint; |
| 63 |
|
| 64 |
/* Vector shift double left */ |
| 65 |
src_va_char = (vector signed char) { 0, 2, 4, 6, 8, 10, 12, 14, |
| 66 |
16, 18, 20, 22, 24, 26, 28, 30 }; |
| 67 |
src_vb_char = (vector signed char) { 10, 20, 30, 40, 50, 60, 70, 80, 90, |
| 68 |
100, 110, 120, 130, 140, 150, 160 }; |
| 69 |
vresult_char = (vector signed char) { 0, 0, 0, 0, 0, 0, 0, 0, |
| 70 |
0, 0, 0, 0, 0, 0, 0, 0 }; |
| 71 |
expected_vresult_char = (vector signed char) { 80, 0, 1, 2, 3, 4, 5, 6, 7, |
| 72 |
8, 9, 10, 11, 12, 13, 14 }; |
| 73 |
|
| 74 |
vresult_char = vec_sldb (src_va_char, src_vb_char, 7); |
| 75 |
|
| 76 |
if (!vec_all_eq (vresult_char, expected_vresult_char)) { |
| 77 |
#if DEBUG |
| 78 |
printf("ERROR, vec_sldb (src_va_char_, src_vb_char, 7)\n"); |
| 79 |
for(i = 0; i < 16; i++) |
| 80 |
printf(" vresult_char[%d] = %d, expected_vresult_char[%d] = %d\n", |
| 81 |
i, vresult_char[i], i, expected_vresult_char[i]); |
| 82 |
#else |
| 83 |
abort(); |
| 84 |
#endif |
| 85 |
} |
| 86 |
|
| 87 |
src_va_uchar = (vector unsigned char) { 0, 2, 4, 6, 8, 10, 12, 14, |
| 88 |
16, 18, 20, 22, 24, 26, 28, 30 }; |
| 89 |
src_vb_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0, |
| 90 |
0, 0, 0, 0, 0, 0, 0, 0 }; |
| 91 |
vresult_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0, |
| 92 |
0, 0, 0, 0, 0, 0, 0, 0 }; |
| 93 |
expected_vresult_uchar = (vector unsigned char) { 0, 0, 1, 2, 3, 4, 5, 6, 7, |
| 94 |
8, 9, 10, 11, 12, 13, 14 }; |
| 95 |
|
| 96 |
vresult_uchar = vec_sldb (src_va_uchar, src_vb_uchar, 7); |
| 97 |
|
| 98 |
if (!vec_all_eq (vresult_uchar, expected_vresult_uchar)) { |
| 99 |
#if DEBUG |
| 100 |
printf("ERROR, vec_sldb (src_va_uchar_, src_vb_uchar, 7)\n"); |
| 101 |
for(i = 0; i < 16; i++) |
| 102 |
printf(" vresult_uchar[%d] = %d, expected_vresult_uchar[%d] = %d\n", |
| 103 |
i, vresult_uchar[i], i, expected_vresult_uchar[i]); |
| 104 |
#else |
| 105 |
abort(); |
| 106 |
#endif |
| 107 |
} |
| 108 |
|
| 109 |
src_va_sh = (vector short int) { 0, 2, 4, 6, 8, 10, 12, 14 }; |
| 110 |
src_vb_sh = (vector short int) { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 111 |
vresult_sh = (vector short int) { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 112 |
expected_vresult_sh = (vector short int) { 0, 2*128, 4*128, 6*128, |
| 113 |
8*128, 10*128, 12*128, 14*128 }; |
| 114 |
|
| 115 |
vresult_sh = vec_sldb (src_va_sh, src_vb_sh, 7); |
| 116 |
|
| 117 |
if (!vec_all_eq (vresult_sh, expected_vresult_sh)) { |
| 118 |
#if DEBUG |
| 119 |
printf("ERROR, vec_sldb (src_va_sh_, src_vb_sh, 7)\n"); |
| 120 |
for(i = 0; i < 8; i++) |
| 121 |
printf(" vresult_sh[%d] = %d, expected_vresult_sh[%d] = %d\n", |
| 122 |
i, vresult_sh[i], i, expected_vresult_sh[i]); |
| 123 |
#else |
| 124 |
abort(); |
| 125 |
#endif |
| 126 |
} |
| 127 |
|
| 128 |
src_va_ush = (vector short unsigned int) { 0, 2, 4, 6, 8, 10, 12, 14 }; |
| 129 |
src_vb_ush = (vector short unsigned int) { 10, 20, 30, 40, 50, 60, 70, 80 }; |
| 130 |
vresult_ush = (vector short unsigned int) { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 131 |
expected_vresult_ush = (vector short unsigned int) { 0, 2*128, 4*128, 6*128, |
| 132 |
8*128, 10*128, 12*128, |
| 133 |
14*128 }; |
| 134 |
|
| 135 |
vresult_ush = vec_sldb (src_va_ush, src_vb_ush, 7); |
| 136 |
|
| 137 |
if (!vec_all_eq (vresult_ush, expected_vresult_ush)) { |
| 138 |
#if DEBUG |
| 139 |
printf("ERROR, vec_sldb (src_va_ush_, src_vb_ush, 7)\n"); |
| 140 |
for(i = 0; i < 8; i++) |
| 141 |
printf(" vresult_ush[%d] = %d, expected_vresult_ush[%d] = %d\n", |
| 142 |
i, vresult_ush[i], i, expected_vresult_ush[i]); |
| 143 |
#else |
| 144 |
abort(); |
| 145 |
#endif |
| 146 |
} |
| 147 |
|
| 148 |
src_va_int = (vector signed int) { 0, 2, 3, 1 }; |
| 149 |
src_vb_int = (vector signed int) { 0, 0, 0, 0 }; |
| 150 |
vresult_int = (vector signed int) { 0, 0, 0, 0 }; |
| 151 |
expected_vresult_int = (vector signed int) { 0, 2*128, 3*128, 1*128 }; |
| 152 |
|
| 153 |
vresult_int = vec_sldb (src_va_int, src_vb_int, 7); |
| 154 |
|
| 155 |
if (!vec_all_eq (vresult_int, expected_vresult_int)) { |
| 156 |
#if DEBUG |
| 157 |
printf("ERROR, vec_sldb (src_va_int_, src_vb_int, 7)\n"); |
| 158 |
for(i = 0; i < 4; i++) |
| 159 |
printf(" vresult_int[%d] = %d, expected_vresult_int[%d] = %d\n", |
| 160 |
i, vresult_int[i], i, expected_vresult_int[i]); |
| 161 |
#else |
| 162 |
abort(); |
| 163 |
#endif |
| 164 |
} |
| 165 |
|
| 166 |
src_va_uint = (vector unsigned int) { 0, 2, 4, 6 }; |
| 167 |
src_vb_uint = (vector unsigned int) { 10, 20, 30, 40 }; |
| 168 |
vresult_uint = (vector unsigned int) { 0, 0, 0, 0 }; |
| 169 |
expected_vresult_uint = (vector unsigned int) { 0, 2*128, 4*128, 6*128 }; |
| 170 |
|
| 171 |
vresult_uint = vec_sldb (src_va_uint, src_vb_uint, 7); |
| 172 |
|
| 173 |
if (!vec_all_eq (vresult_uint, expected_vresult_uint)) { |
| 174 |
#if DEBUG |
| 175 |
printf("ERROR, vec_sldb (src_va_uint_, src_vb_uint, 7)\n"); |
| 176 |
for(i = 0; i < 4; i++) |
| 177 |
printf(" vresult_uint[%d] = %d, expected_vresult_uint[%d] = %d\n", |
| 178 |
i, vresult_uint[i], i, expected_vresult_uint[i]); |
| 179 |
#else |
| 180 |
abort(); |
| 181 |
#endif |
| 182 |
} |
| 183 |
|
| 184 |
src_va_llint = (vector signed long long int) { 5, 6 }; |
| 185 |
src_vb_llint = (vector signed long long int) { 0, 0 }; |
| 186 |
vresult_llint = (vector signed long long int) { 0, 0 }; |
| 187 |
expected_vresult_llint = (vector signed long long int) { 5*128, 6*128 }; |
| 188 |
|
| 189 |
vresult_llint = vec_sldb (src_va_llint, src_vb_llint, 7); |
| 190 |
|
| 191 |
if (!vec_all_eq (vresult_llint, expected_vresult_llint)) { |
| 192 |
#if DEBUG |
| 193 |
printf("ERROR, vec_sldb (src_va_llint_, src_vb_llint, 7)\n"); |
| 194 |
for(i = 0; i < 2; i++) |
| 195 |
printf(" vresult_llint[%d] = %d, expected_vresult_llint[%d] = %d\n", |
| 196 |
i, vresult_llint[i], i, expected_vresult_llint[i]); |
| 197 |
#else |
| 198 |
abort(); |
| 199 |
#endif |
| 200 |
} |
| 201 |
|
| 202 |
src_va_ullint = (vector unsigned long long int) { 54, 26 }; |
| 203 |
src_vb_ullint = (vector unsigned long long int) { 10, 20 }; |
| 204 |
vresult_ullint = (vector unsigned long long int) { 0, 0 }; |
| 205 |
expected_vresult_ullint = (vector unsigned long long int) { 54*128, |
| 206 |
26*128 }; |
| 207 |
|
| 208 |
vresult_ullint = vec_sldb (src_va_ullint, src_vb_ullint, 7); |
| 209 |
|
| 210 |
if (!vec_all_eq (vresult_ullint, expected_vresult_ullint)) { |
| 211 |
#if DEBUG |
| 212 |
printf("ERROR, vec_sldb (src_va_ullint_, src_vb_ullint, 7)\n"); |
| 213 |
for(i = 0; i < 2; i++) |
| 214 |
printf(" vresult_ullint[%d] = %d, expected_vresult_ullint[%d] = %d\n", |
| 215 |
i, vresult_ullint[i], i, expected_vresult_ullint[i]); |
| 216 |
#else |
| 217 |
abort(); |
| 218 |
#endif |
| 219 |
} |
| 220 |
|
| 221 |
/* Vector shift double right */ |
| 222 |
src_va_char = (vector signed char) { 0, 2, 4, 6, 8, 10, 12, 14, |
| 223 |
16, 18, 20, 22, 24, 26, 28, 30 }; |
| 224 |
src_vb_char = (vector signed char) { 10, 12, 14, 16, 18, 20, 22, 24, 26, |
| 225 |
28, 30, 32, 34, 36, 38, 40 }; |
| 226 |
vresult_char = (vector signed char) { 0, 0, 0, 0, 0, 0, 0, 0, |
| 227 |
0, 0, 0, 0, 0, 0, 0, 0 }; |
| 228 |
expected_vresult_char = (vector signed char) { 24, 28, 32, 36, 40, 44, 48, |
| 229 |
52, 56, 60, 64, 68, 72, 76, |
| 230 |
80, 0 }; |
| 231 |
|
| 232 |
vresult_char = vec_srdb (src_va_char, src_vb_char, 7); |
| 233 |
|
| 234 |
if (!vec_all_eq (vresult_char, expected_vresult_char)) { |
| 235 |
#if DEBUG |
| 236 |
printf("ERROR, vec_srdb (src_va_char_, src_vb_char, 7)\n"); |
| 237 |
for(i = 0; i < 16; i++) |
| 238 |
printf(" vresult_char[%d] = %d, expected_vresult_char[%d] = %d\n", |
| 239 |
i, vresult_char[i], i, expected_vresult_char[i]); |
| 240 |
#else |
| 241 |
abort(); |
| 242 |
#endif |
| 243 |
} |
| 244 |
|
| 245 |
src_va_uchar = (vector unsigned char) { 100, 0, 0, 0, 0, 0, 0, 0, |
| 246 |
0, 0, 0, 0, 0, 0, 0, 0 }; |
| 247 |
src_vb_uchar = (vector unsigned char) { 0, 2, 4, 6, 8, 10, 12, 14, |
| 248 |
16, 18, 20, 22, 24, 26, 28, 30 }; |
| 249 |
vresult_uchar = (vector unsigned char) { 0, 0, 0, 0, 0, 0, 0, 0, |
| 250 |
0, 0, 0, 0, 0, 0, 0, 0 }; |
| 251 |
expected_vresult_uchar = (vector unsigned char) { 4, 8, 12, 16, 20, 24, 28, |
| 252 |
32, 36, 40, 44, 48, 52, |
| 253 |
56, 60, 200 }; |
| 254 |
|
| 255 |
vresult_uchar = vec_srdb (src_va_uchar, src_vb_uchar, 7); |
| 256 |
|
| 257 |
if (!vec_all_eq (vresult_uchar, expected_vresult_uchar)) { |
| 258 |
#if DEBUG |
| 259 |
printf("ERROR, vec_srdb (src_va_uchar_, src_vb_uchar, 7)\n"); |
| 260 |
for(i = 0; i < 16; i++) |
| 261 |
printf(" vresult_uchar[%d] = %d, expected_vresult_uchar[%d] = %d\n", |
| 262 |
i, vresult_uchar[i], i, expected_vresult_uchar[i]); |
| 263 |
#else |
| 264 |
abort(); |
| 265 |
#endif |
| 266 |
} |
| 267 |
|
| 268 |
src_va_sh = (vector short int) { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 269 |
src_vb_sh = (vector short int) { 0, 2*128, 4*128, 6*128, |
| 270 |
8*128, 10*128, 12*128, 14*128 }; |
| 271 |
vresult_sh = (vector short int) { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 272 |
expected_vresult_sh = (vector short int) { 0, 2, 4, 6, 8, 10, 12, 14 }; |
| 273 |
|
| 274 |
vresult_sh = vec_srdb (src_va_sh, src_vb_sh, 7); |
| 275 |
|
| 276 |
if (!vec_all_eq (vresult_sh, expected_vresult_sh)) { |
| 277 |
#if DEBUG |
| 278 |
printf("ERROR, vec_srdb (src_va_sh_, src_vb_sh, 7)\n"); |
| 279 |
for(i = 0; i < 8; i++) |
| 280 |
printf(" vresult_sh[%d] = %d, expected_vresult_sh[%d] = %d\n", |
| 281 |
i, vresult_sh[i], i, expected_vresult_sh[i]); |
| 282 |
#else |
| 283 |
abort(); |
| 284 |
#endif |
| 285 |
} |
| 286 |
|
| 287 |
src_va_ush = (vector short unsigned int) { 0, 20, 30, 40, 50, 60, 70, 80 }; |
| 288 |
src_vb_ush = (vector short unsigned int) { 0, 2*128, 4*128, 6*128, |
| 289 |
8*128, 10*128, 12*128, 14*128 }; |
| 290 |
vresult_ush = (vector short unsigned int) { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 291 |
expected_vresult_ush = (vector short unsigned int) { 0, 2, 4, 6, 8, 10, |
| 292 |
12, 14 }; |
| 293 |
|
| 294 |
vresult_ush = vec_srdb (src_va_ush, src_vb_ush, 7); |
| 295 |
|
| 296 |
if (!vec_all_eq (vresult_ush, expected_vresult_ush)) { |
| 297 |
#if DEBUG |
| 298 |
printf("ERROR, vec_srdb (src_va_ush_, src_vb_ush, 7)\n"); |
| 299 |
for(i = 0; i < 8; i++) |
| 300 |
printf(" vresult_ush[%d] = %d, expected_vresult_ush[%d] = %d\n", |
| 301 |
i, vresult_ush[i], i, expected_vresult_ush[i]); |
| 302 |
#else |
| 303 |
abort(); |
| 304 |
#endif |
| 305 |
} |
| 306 |
|
| 307 |
src_va_int = (vector signed int) { 0, 0, 0, 0 }; |
| 308 |
src_vb_int = (vector signed int) { 0, 2*128, 3*128, 1*128 }; |
| 309 |
vresult_int = (vector signed int) { 0, 0, 0, 0 }; |
| 310 |
expected_vresult_int = (vector signed int) { 0, 2, 3, 1 }; |
| 311 |
|
| 312 |
vresult_int = vec_srdb (src_va_int, src_vb_int, 7); |
| 313 |
|
| 314 |
if (!vec_all_eq (vresult_int, expected_vresult_int)) { |
| 315 |
#if DEBUG |
| 316 |
printf("ERROR, vec_srdb (src_va_int_, src_vb_int, 7)\n"); |
| 317 |
for(i = 0; i < 4; i++) |
| 318 |
printf(" vresult_int[%d] = %d, expected_vresult_int[%d] = %d\n", |
| 319 |
i, vresult_int[i], i, expected_vresult_int[i]); |
| 320 |
#else |
| 321 |
abort(); |
| 322 |
#endif |
| 323 |
} |
| 324 |
|
| 325 |
src_va_uint = (vector unsigned int) { 0, 20, 30, 40 }; |
| 326 |
src_vb_uint = (vector unsigned int) { 128, 2*128, 4*128, 6*128 }; |
| 327 |
vresult_uint = (vector unsigned int) { 0, 0, 0, 0 }; |
| 328 |
expected_vresult_uint = (vector unsigned int) { 1, 2, 4, 6 }; |
| 329 |
|
| 330 |
vresult_uint = vec_srdb (src_va_uint, src_vb_uint, 7); |
| 331 |
|
| 332 |
if (!vec_all_eq (vresult_uint, expected_vresult_uint)) { |
| 333 |
#if DEBUG |
| 334 |
printf("ERROR, vec_srdb (src_va_uint_, src_vb_uint, 7)\n"); |
| 335 |
for(i = 0; i < 4; i++) |
| 336 |
printf(" vresult_uint[%d] = %d, expected_vresult_uint[%d] = %d\n", |
| 337 |
i, vresult_uint[i], i, expected_vresult_uint[i]); |
| 338 |
#else |
| 339 |
abort(); |
| 340 |
#endif |
| 341 |
} |
| 342 |
|
| 343 |
src_va_llint = (vector signed long long int) { 0, 0 }; |
| 344 |
src_vb_llint = (vector signed long long int) { 5*128, 6*128 }; |
| 345 |
vresult_llint = (vector signed long long int) { 0, 0 }; |
| 346 |
expected_vresult_llint = (vector signed long long int) { 5, 6 }; |
| 347 |
|
| 348 |
vresult_llint = vec_srdb (src_va_llint, src_vb_llint, 7); |
| 349 |
|
| 350 |
if (!vec_all_eq (vresult_llint, expected_vresult_llint)) { |
| 351 |
#if DEBUG |
| 352 |
printf("ERROR, vec_srdb (src_va_llint_, src_vb_llint, 7)\n"); |
| 353 |
for(i = 0; i < 2; i++) |
| 354 |
printf(" vresult_llint[%d] = %d, expected_vresult_llint[%d] = %d\n", |
| 355 |
i, vresult_llint[i], i, expected_vresult_llint[i]); |
| 356 |
#else |
| 357 |
abort(); |
| 358 |
#endif |
| 359 |
} |
| 360 |
|
| 361 |
src_va_ullint = (vector unsigned long long int) { 0, 0 }; |
| 362 |
src_vb_ullint = (vector unsigned long long int) { 54*128, 26*128 }; |
| 363 |
vresult_ullint = (vector unsigned long long int) { 0, 0 }; |
| 364 |
expected_vresult_ullint = (vector unsigned long long int) { 54, 26 }; |
| 365 |
|
| 366 |
vresult_ullint = vec_srdb (src_va_ullint, src_vb_ullint, 7); |
| 367 |
|
| 368 |
if (!vec_all_eq (vresult_ullint, expected_vresult_ullint)) { |
| 369 |
#if DEBUG |
| 370 |
printf("ERROR, vec_srdb (src_va_ullint_, src_vb_ullint, 7)\n"); |
| 371 |
for(i = 0; i < 2; i++) |
| 372 |
printf(" vresult_ullint[%d] = %d, expected_vresult_ullint[%d] = %d\n", |
| 373 |
i, vresult_ullint[i], i, expected_vresult_ullint[i]); |
| 374 |
#else |
| 375 |
abort(); |
| 376 |
#endif |
| 377 |
} |
| 378 |
|
| 379 |
return 0; |
| 380 |
} |
| 381 |
|
| 382 |
/* { dg-final { scan-assembler-times {\mvsldbi\M} 8 } } */ |
| 383 |
/* { dg-final { scan-assembler-times {\mvsrdbi\M} 8 } } */ |