| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target p9vector_hw } */ |
| 3 |
/* { dg-require-effective-target int128 } */ |
| 4 |
/* { dg-options "-mdejagnu-cpu=power9 -O2" } */ |
| 5 |
|
| 6 |
#include <altivec.h> // vector |
| 7 |
|
| 8 |
void abort (void); |
| 9 |
|
| 10 |
int main() { |
| 11 |
int i; |
| 12 |
vector int vsia; |
| 13 |
vector unsigned int vsir, vsiexpt; |
| 14 |
vector unsigned int vuia, vuir, vuiexpt; |
| 15 |
vector signed long long vslla; |
| 16 |
vector unsigned long long vsllr, vsllexpt; |
| 17 |
vector unsigned long long vulla, vullr, vullexpt; |
| 18 |
vector __int128_t vs128a; |
| 19 |
vector __uint128_t vs128r, vs128expt; |
| 20 |
vector __uint128_t vu128a, vu128r, vu128expt; |
| 21 |
|
| 22 |
/* Returns a vector with each element containing the parity of the low-order |
| 23 |
bit of each of the bytes in that element. Note results are always |
| 24 |
returned in an unsinged type, per the ABI spec. */ |
| 25 |
vsia = (vector int) {0x10101010, 0x10101011, 0x10101111, 0x10111111}; |
| 26 |
vsiexpt = (vector unsigned int){0x0, 0x1, 0x0, 0x1}; |
| 27 |
|
| 28 |
vuia = (vector unsigned int) {0x000010000, 0x00010001, |
| 29 |
0x10100000, 0x000010101}; |
| 30 |
vuiexpt = (vector unsigned int){0x1, 0x0, 0x0, 0x1}; |
| 31 |
|
| 32 |
vslla = (vector long long) {0x0000000000010000, 0x0001000100010000}; |
| 33 |
vsllexpt = (vector unsigned long long){0x1, 0x1}; |
| 34 |
|
| 35 |
vulla = (vector unsigned long long) {0x0000000000000001, |
| 36 |
0x0001000000000001}; |
| 37 |
vullexpt = (vector unsigned long long){0x1, 0x0}; |
| 38 |
|
| 39 |
vs128a = (vector __int128_t) {0x0000000000001}; |
| 40 |
vs128expt = (vector __uint128_t) {0x1}; |
| 41 |
vu128a = (vector __uint128_t) {0x1000000000001}; |
| 42 |
vu128expt = (vector __uint128_t) {0x0}; |
| 43 |
|
| 44 |
vsir = vec_parity_lsbb(vsia); |
| 45 |
vuir = vec_parity_lsbb(vuia); |
| 46 |
vsllr = vec_parity_lsbb(vslla); |
| 47 |
vullr = vec_parity_lsbb(vulla); |
| 48 |
vs128r = vec_parity_lsbb(vs128a); |
| 49 |
vu128r = vec_parity_lsbb(vu128a); |
| 50 |
|
| 51 |
for(i = 0; i< 4; i++) { |
| 52 |
if (vsir[i] != vsiexpt[i]) |
| 53 |
abort(); |
| 54 |
|
| 55 |
if (vuir[i] != vuiexpt[i]) |
| 56 |
abort(); |
| 57 |
} |
| 58 |
|
| 59 |
for(i = 0; i< 2; i++) { |
| 60 |
if (vsllr[i] != vsllexpt[i]) |
| 61 |
abort(); |
| 62 |
|
| 63 |
if (vullr[i] != vullexpt[i]) |
| 64 |
abort(); |
| 65 |
} |
| 66 |
|
| 67 |
if (vs128r[0] != vs128expt[0]) |
| 68 |
abort(); |
| 69 |
|
| 70 |
if (vu128r[0] != vu128expt[0]) |
| 71 |
abort(); |
| 72 |
} |