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