2 Test of vec_xst_trunc (truncate and store rightmost vector element) */
4 /* { dg-do run { target power10_hw } } */
5 /* { dg-do compile { target { ! power10_hw } } } */
6 /* { dg-require-effective-target power10_ok } */
7 /* { dg-require-effective-target int128 } */
9 /* Deliberately set optization to zero for this test to confirm
10 the stxvr*x instruction is generated. At higher optimization levels
11 the instruction we are looking for is sometimes replaced by other
12 store instructions. */
13 /* { dg-options "-mdejagnu-cpu=power10 -O0 -save-temps" } */
15 /* { dg-final { scan-assembler-times {\mstxvrhx\M} 2 } } */
16 /* { dg-final { scan-assembler-times {\msthx\M} 0 } } */
24 vector
signed __int128 store_this_s
[4] = {
25 { (__int128
) 0x7000000000000000 << 64 | (__int128
) 0x123456789abcdef8ULL
},
26 { (__int128
) 0x8000000000000000 << 64 | (__int128
) 0xfedcba9876543217ULL
},
27 { (__int128
) 0x1000000000000000 << 64 | (__int128
) 0xccccccccccccccccULL
},
28 { (__int128
) 0xf000000000000000 << 64 | (__int128
) 0xaaaaaaaaaaaaaaaaULL
}
31 vector
unsigned __int128 store_this_us
[4] = {
32 { (unsigned __int128
) 0x7000000000000000 << 64 | (unsigned __int128
) 0x123456789abcdef8ULL
},
33 { (unsigned __int128
) 0x8000000000000000 << 64 | (unsigned __int128
) 0xfedcba9876543217ULL
},
34 { (unsigned __int128
) 0x1000000000000000 << 64 | (unsigned __int128
) 0xeeeeeeeeeeeeeeeeULL
},
35 { (unsigned __int128
) 0xf000000000000000 << 64 | (unsigned __int128
) 0x5555555555555555ULL
}
38 #define NUM_VEC_ELEMS 8
40 vector
signed short signed_expected
[4] = {
41 {0xdef8, 0x0, 0x0 , 0x0, 0x0 , 0x0, 0x0 , 0x0},
42 {0x0 , 0x0, 0x3217, 0x0, 0x0 , 0x0, 0x0 , 0x0},
43 {0x0 , 0x0, 0x0 , 0x0, 0xcccc, 0x0, 0x0 , 0x0},
44 {0x0 , 0x0, 0x0 , 0x0, 0x0 , 0x0, 0xaaaa, 0x0}
46 vector
unsigned short unsigned_expected
[4] = {
47 {0xdef8, 0x0, 0x0 , 0x0, 0x0 , 0x0, 0x0 , 0x0},
48 {0x0 , 0x0, 0x3217, 0x0, 0x0 , 0x0, 0x0 , 0x0},
49 {0x0 , 0x0, 0x0 , 0x0, 0xeeee, 0x0, 0x0 , 0x0},
50 {0x0 , 0x0, 0x0 , 0x0, 0x0 , 0x0, 0x5555, 0x0}
53 unsigned long long rawbuffer
[32];
54 signed short * vsbuffer
= (short *)rawbuffer
;
55 unsigned short * vubuffer
= (unsigned short *)rawbuffer
;
58 memset (&rawbuffer
,0,sizeof(rawbuffer
));
61 #define PRINT_VEC(V) \
62 for (int j=0;j<NUM_VEC_ELEMS;j++) { printf ("(0x%lx) ", V[j] ); }
64 void test_signed_store(vector
signed __int128 myvec
, int offset
, signed short * store_data
) {
65 vec_xst_trunc (myvec
, offset
, store_data
);
68 void test_unsigned_store(vector
unsigned __int128 myvec
, int offset
, unsigned short * store_data
) {
69 vec_xst_trunc (myvec
, offset
, store_data
);
72 int main (int argc
, char *argv
[])
81 printf("%s %s\n", __DATE__
, __TIME__
);
85 printf("expected results from signed tests:\n");
86 for (i
= 0; i
< 4 ; i
++ ) {
87 PRINT_VEC(signed_expected
[i
]);
92 for (i
= 0; i
< 4 ; i
++ ) {
94 test_signed_store (store_this_s
[i
], 4*i
, vsbuffer
);
95 memcmpresult
= memcmp(rawbuffer
,&signed_expected
[i
],sizeof(vector
short));
97 printf("mismatch signed buffer, i %d (memcmpresult:%d) \n",i
,memcmpresult
);
107 for (i
= 0; i
< 4 ; i
++ ) {
109 test_unsigned_store (store_this_us
[i
], 4*i
, vubuffer
);
110 memcmpresult
= memcmp(rawbuffer
,&unsigned_expected
[i
],sizeof(vector
short));
112 printf("mismatch unsigned buffer, i %d (memcmpresult:%d) \n",i
,memcmpresult
);
123 printf("%d mismatches. \n",mismatch
);