| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target p8vector_hw } */ |
| 3 |
/* { dg-options "-mdejagnu-cpu=power8 -O2" } */ |
| 4 |
|
| 5 |
#include <stdint.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include <inttypes.h> |
| 8 |
#include <altivec.h> |
| 9 |
|
| 10 |
#ifdef DEBUG |
| 11 |
#include <stdio.h> |
| 12 |
#endif |
| 13 |
|
| 14 |
void abort (void); |
| 15 |
|
| 16 |
int main() { |
| 17 |
int i; |
| 18 |
vector bool char ubc_arg1, ubc_arg2, ubc_arg3; |
| 19 |
vector unsigned char uc_arg1, uc_arg2, uc_arg3; |
| 20 |
vector signed char sc_arg1, sc_arg2, sc_arg3; |
| 21 |
|
| 22 |
vector bool char vec_ubc_expected1, vec_ubc_result1; |
| 23 |
vector unsigned char vec_uc_expected1, vec_uc_result1; |
| 24 |
vector signed char vec_sc_expected1, vec_sc_result1; |
| 25 |
|
| 26 |
/* vec_permxor: bool char args, result */ |
| 27 |
ubc_arg1 = (vector bool char){0xA, 0x2, 0xB0, 0x4, |
| 28 |
0x5, 0x6, 0x7, 0x8, |
| 29 |
0x9, 0x10, 0x11, 0x12, |
| 30 |
0x13, 0x15, 0x15, 0x16}; |
| 31 |
ubc_arg2 = (vector bool char){0x5, 0x20, 0xC, 0x40, |
| 32 |
0x55, 0x66, 0x77, 0x88, |
| 33 |
0x9, 0xFF, 0x0, 0xED, |
| 34 |
0x4, 0x5, 0x6, 0x7}; |
| 35 |
ubc_arg3 = (vector bool char){0x08, 0x19, 0x2A, 0x3B, |
| 36 |
0x4D, 0x5C, 0x6D, 0x7E, |
| 37 |
0x8F, 0x90, 0xA1, 0xB2, |
| 38 |
0xC3, 0xD4, 0xE5, 0xF6}; |
| 39 |
vec_ubc_expected1 = (vector bool char){0x3, 0xFD, 0xB0, 0xE9, |
| 40 |
0x0, 0x2, 0x2, 0xE, |
| 41 |
0xE, 0x15, 0x31, 0x1E, |
| 42 |
0x53, 0x40, 0x73, 0x61}; |
| 43 |
vec_ubc_result1 = vec_permxor (ubc_arg1, ubc_arg2, ubc_arg3); |
| 44 |
|
| 45 |
for (i = 0; i < 16; i++) { |
| 46 |
if (vec_ubc_expected1[i] != vec_ubc_result1[i]) |
| 47 |
#ifdef DEBUG |
| 48 |
printf("ERROR vec_permxor (ubc, ubc, ubc) result[%d]=0x%x != expected[%d]=0x%x\n", |
| 49 |
i, vec_ubc_result1[i], i, vec_ubc_expected1[i]); |
| 50 |
#else |
| 51 |
abort(); |
| 52 |
#endif |
| 53 |
} |
| 54 |
|
| 55 |
/* vec_permxor: signed char args, result */ |
| 56 |
sc_arg1 = (vector signed char){0x1, 0x2, 0x3, 0x4, |
| 57 |
0x5, 0x6, 0x7, 0x8, |
| 58 |
0x9, 0x10, 0xA, 0xB, |
| 59 |
0xC, 0xD, 0xE, 0xF}; |
| 60 |
sc_arg2 = (vector signed char){0x5, 0x5, 0x7, 0x8, |
| 61 |
0x9, 0xA, 0xB, 0xC, |
| 62 |
0xD, 0xE, 0xF, 0x0, |
| 63 |
0x1, 0x2, 0x3, 0x4}; |
| 64 |
sc_arg3 = (vector signed char){0x08, 0x19, 0x2A, 0x3B, |
| 65 |
0x4D, 0x5C, 0x6D, 0x7E, |
| 66 |
0x8F, 0x90, 0xA1, 0xB2, |
| 67 |
0xC3, 0xD4, 0xE5, 0xF6}; |
| 68 |
vec_sc_expected1 = (vector signed char){0xC, 0xC, 0xC, 0x4, |
| 69 |
0x7, 0x7, 0x5, 0xB, |
| 70 |
0xD, 0x15, 0xF, 0xC, |
| 71 |
0x4, 0x4, 0x4, 0x4}; |
| 72 |
vec_sc_result1 = vec_permxor (sc_arg1, sc_arg2, sc_arg3); |
| 73 |
|
| 74 |
for (i = 0; i < 16; i++) { |
| 75 |
if (vec_sc_expected1[i] != vec_sc_result1[i]) |
| 76 |
#ifdef DEBUG |
| 77 |
printf("ERROR vec_permxor (sc, sc, sc) result[%d]=0x%x != expected[%d]=0x%x\n", |
| 78 |
i, vec_sc_result1[i], i, vec_sc_expected1[i]); |
| 79 |
#else |
| 80 |
abort(); |
| 81 |
#endif |
| 82 |
} |
| 83 |
|
| 84 |
/* vec_permxor: unsigned char args, result */ |
| 85 |
uc_arg1 = (vector unsigned char){0xA, 0xB, 0xC, 0xD, |
| 86 |
0xE, 0xF, 0x0, 0x1, |
| 87 |
0x2, 0x3, 0x4, 0x5, |
| 88 |
0x6, 0x7, 0x8, 0x9}; |
| 89 |
uc_arg2 = (vector unsigned char){0x5, 0x6, 0x7, 0x8, |
| 90 |
0x9, 0xA, 0xB, 0xC, |
| 91 |
0xD, 0xE, 0xF, 0x0, |
| 92 |
0x1, 0x2, 0x3, 0x4}; |
| 93 |
uc_arg3 = (vector unsigned char){0x08, 0x19, 0x2A, 0x3B, |
| 94 |
0x4D, 0x5C, 0x6D, 0x7E, |
| 95 |
0x8F, 0x90, 0xA1, 0xB2, |
| 96 |
0xC3, 0xD4, 0xE5, 0xF6}; |
| 97 |
vec_uc_expected1 = (vector unsigned char){0x7, 0x5, 0x3, 0xD, |
| 98 |
0xC, 0xE, 0x2, 0x2, |
| 99 |
0x6, 0x6, 0x2, 0x2, |
| 100 |
0xE, 0xE, 0x2, 0x2}; |
| 101 |
vec_uc_result1 = vec_permxor (uc_arg1, uc_arg2, uc_arg3); |
| 102 |
|
| 103 |
for (i = 0; i < 16; i++) { |
| 104 |
if (vec_uc_expected1[i] != vec_uc_result1[i]) |
| 105 |
#ifdef DEBUG |
| 106 |
printf("ERROR vec_permxor (uc, uc, uc) result[%d]=0x%x != expected[%d]=0x%x\n", |
| 107 |
i, vec_uc_result1[i], i, vec_uc_expected1[i]); |
| 108 |
#else |
| 109 |
abort(); |
| 110 |
#endif |
| 111 |
} |
| 112 |
} |