2 Test of vec_xst_trunc (truncate and store rightmost vector element) */
4 /* { dg-do compile {target power10_ok} } */
5 /* { dg-do run {target power10_hw} } */
6 /* { dg-require-effective-target int128 } */
7 /* Deliberately set optization to zero for this test to confirm
8 the stxvr*x instruction is generated. At higher optimization levels
9 the instruction we are looking for is sometimes replaced by other
10 store instructions. */
11 /* { dg-options "-mdejagnu-cpu=power10 -O0" } */
13 /* { dg-final { scan-assembler-times {\mstxvrbx\M} 2 } } */
14 /* { dg-final { scan-assembler-times {\mstbx\M} 0 } } */
22 vector
signed __int128 store_this_s
[4] = {
23 { (__int128
) 0x7000000000000000 << 64 | (__int128
) 0x123456789abcdef8ULL
},
24 { (__int128
) 0x8000000000000000 << 64 | (__int128
) 0xfedcba9876543217ULL
},
25 { (__int128
) 0x1000000000000000 << 64 | (__int128
) 0xccccccccccccccccULL
},
26 { (__int128
) 0xf000000000000000 << 64 | (__int128
) 0xaaaaaaaaaaaaaaaaULL
}
29 vector
unsigned __int128 store_this_us
[4] = {
30 { (unsigned __int128
) 0x7000000000000000 << 64 | (unsigned __int128
) 0x123456789abcdef8ULL
},
31 { (unsigned __int128
) 0x8000000000000000 << 64 | (unsigned __int128
) 0xfedcba9876543217ULL
},
32 { (unsigned __int128
) 0x1000000000000000 << 64 | (unsigned __int128
) 0xeeeeeeeeeeeeeeeeULL
},
33 { (unsigned __int128
) 0xf000000000000000 << 64 | (unsigned __int128
) 0x5555555555555555ULL
}
36 #define NUM_VEC_ELEMS 16
38 vector
signed char signed_expected
[4] = {
39 { 0xf8, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0},
40 { 0x0 , 0x0, 0x0, 0x0, 0x17, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0},
41 { 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0xcc, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0},
42 { 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0xaa, 0x0, 0x0, 0x0}
44 vector
unsigned char unsigned_expected
[4] = {
45 { 0xf8, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0},
46 { 0x0 , 0x0, 0x0, 0x0, 0x17, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0},
47 { 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0xee, 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0},
48 { 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x0 , 0x0, 0x0, 0x0, 0x55, 0x0, 0x0, 0x0}
51 unsigned long long rawbuffer
[32];
52 signed char * vsbuffer
= (char *)rawbuffer
;
53 unsigned char * vubuffer
= (unsigned char *)rawbuffer
;
56 memset (&rawbuffer
,0,sizeof(rawbuffer
));
59 #define PRINT_VEC(V) \
60 for (int j=0;j<NUM_VEC_ELEMS;j++) { printf ("(0x%lx) ", V[j] ); }
62 void test_signed_store(vector
signed __int128 myvec
, int offset
, signed char * store_data
) {
63 vec_xst_trunc (myvec
, offset
, store_data
);
66 void test_unsigned_store(vector
unsigned __int128 myvec
, int offset
, unsigned char * store_data
) {
67 vec_xst_trunc (myvec
, offset
, store_data
);
70 int main (int argc
, char *argv
[])
79 printf("%s %s\n", __DATE__
, __TIME__
);
83 printf("expected results from signed tests:\n");
84 for (i
= 0; i
< 4 ; i
++ ) {
85 PRINT_VEC(signed_expected
[i
]);
90 for (i
= 0; i
< 4 ; i
++ ) {
92 test_signed_store (store_this_s
[i
], 4*i
, vsbuffer
);
93 memcmpresult
= memcmp(rawbuffer
,&signed_expected
[i
],sizeof(vector
char));
95 printf("mismatch signed buffer, i %d (memcmpresult:%d) \n",i
,memcmpresult
);
105 for (i
= 0; i
< 4 ; i
++ ) {
107 test_unsigned_store (store_this_us
[i
], 4*i
, vubuffer
);
108 memcmpresult
= memcmp(rawbuffer
,&unsigned_expected
[i
],sizeof(vector
char));
110 printf("mismatch unsigned buffer, i %d (memcmpresult:%d) \n",i
,memcmpresult
);
121 printf("%d mismatches. \n",mismatch
);