| 1 |
/* Test of __builtin_vec_xst_trunc */ |
| 2 |
|
| 3 |
/* { dg-do run { target power10_hw } } */ |
| 4 |
/* { dg-require-effective-target int128 } */ |
| 5 |
/* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */ |
| 6 |
|
| 7 |
#include <altivec.h> |
| 8 |
#include <stdio.h> |
| 9 |
#include <inttypes.h> |
| 10 |
#include <string.h> |
| 11 |
#include <stdlib.h> |
| 12 |
|
| 13 |
#define DEBUG 0 |
| 14 |
|
| 15 |
vector signed __int128 store_data = |
| 16 |
{ (__int128) 0x8ACE000000000000 << 64 | (__int128) 0xfedcba9876543217ULL}; |
| 17 |
|
| 18 |
union conv_t { |
| 19 |
vector signed __int128 vsi128; |
| 20 |
unsigned long long ull[2]; |
| 21 |
} conv; |
| 22 |
|
| 23 |
void abort (void); |
| 24 |
|
| 25 |
|
| 26 |
int |
| 27 |
main () { |
| 28 |
int i; |
| 29 |
signed long sl; |
| 30 |
signed char sc[2], expected_sc; |
| 31 |
signed short ss[2], expected_ss; |
| 32 |
signed int si[2], expected_si; |
| 33 |
signed long long int sll[2], expected_sll; |
| 34 |
signed char *psc; |
| 35 |
signed short *pss; |
| 36 |
signed int *psi; |
| 37 |
signed long long int *psll; |
| 38 |
|
| 39 |
#if DEBUG |
| 40 |
val.vsi128 = store_data; |
| 41 |
printf("Data to store [%d] = 0x%llx %llx\n", i, val.ull[1], val.ull[0]); |
| 42 |
#endif |
| 43 |
|
| 44 |
psc = &sc[0]; |
| 45 |
pss = &ss[0]; |
| 46 |
psi = &si[0]; |
| 47 |
psll = &sll[0]; |
| 48 |
|
| 49 |
sl = 1; |
| 50 |
sc[0] = 0xA1; |
| 51 |
expected_sc = 0xA1; |
| 52 |
__builtin_altivec_tr_stxvrbx (store_data, sl, psc); |
| 53 |
|
| 54 |
if (expected_sc != sc[0] & 0xFF) |
| 55 |
#if DEBUG |
| 56 |
printf(" ERROR: Signed char = 0x%x doesn't match expected value 0x%x\n", |
| 57 |
sc[0] & 0xFF, expected_sc); |
| 58 |
#else |
| 59 |
abort(); |
| 60 |
#endif |
| 61 |
|
| 62 |
ss[0] = 0x52; |
| 63 |
expected_ss = 0x1752; |
| 64 |
__builtin_altivec_tr_stxvrhx (store_data, sl, pss); |
| 65 |
|
| 66 |
if (expected_ss != ss[0] & 0xFFFF) |
| 67 |
#if DEBUG |
| 68 |
printf(" ERROR: Signed short = 0x%x doesn't match expected value 0x%x\n", |
| 69 |
ss[0], expected_ss) & 0xFFFF; |
| 70 |
#else |
| 71 |
abort(); |
| 72 |
#endif |
| 73 |
|
| 74 |
si[0] = 0x21; |
| 75 |
expected_si = 0x54321721; |
| 76 |
__builtin_altivec_tr_stxvrwx (store_data, sl, psi); |
| 77 |
|
| 78 |
if (expected_si != si[0]) |
| 79 |
#if DEBUG |
| 80 |
printf(" ERROR: Signed int = 0x%x doesn't match expected value 0x%x\n", |
| 81 |
si[0], expected_si); |
| 82 |
#else |
| 83 |
abort(); |
| 84 |
#endif |
| 85 |
|
| 86 |
sll[0] = 0x12FFULL; |
| 87 |
expected_sll = 0xdcba9876543217FF; |
| 88 |
__builtin_altivec_tr_stxvrdx (store_data, sl, psll); |
| 89 |
|
| 90 |
if (expected_sll != sll[0]) |
| 91 |
#if DEBUG |
| 92 |
printf(" ERROR: Signed long long int = 0x%llx doesn't match expected value 0x%llx\n", |
| 93 |
sll[0], expected_sll); |
| 94 |
#else |
| 95 |
abort(); |
| 96 |
#endif |
| 97 |
|
| 98 |
return 0; |
| 99 |
} |
| 100 |
|
| 101 |
/* { dg-final { scan-assembler-times {\mstxvrbx\M} 1 } } */ |
| 102 |
/* { dg-final { scan-assembler-times {\mstxvrhx\M} 1 } } */ |
| 103 |
/* { dg-final { scan-assembler-times {\mstxvrwx\M} 1 } } */ |
| 104 |
/* { dg-final { scan-assembler-times {\mstxvrdx\M} 1 } } */ |