2 Test of vec_xl_sext and vec_xl_zext (load into rightmost
3 vector element and zero/sign extend). */
5 /* { dg-do run { target power10_hw } } */
6 /* { dg-do compile { target { ! power10_hw } } } */
7 /* { dg-require-effective-target power10_ok } */
8 /* { dg-require-effective-target int128 } */
10 /* Deliberately set optization to zero for this test to confirm
11 the lxvr*x instruction is generated. At higher optimization levels
12 the instruction we are looking for is sometimes replaced by other
14 /* { dg-options "-mdejagnu-cpu=power10 -O0 -save-temps" } */
16 /* { dg-final { scan-assembler-times {\mlxvrwx\M} 2 } } */
18 #define NUM_VEC_ELEMS 4
22 Codegen at time of writing is a single lxvrwx for the zero
23 extended test, and a lwax,mtvsrdd,vextsd2q for the sign
26 0000000010000c90 <test_sign_extended_load>:
27 10000c90: aa 1a 24 7d lwax r9,r4,r3
28 10000c94: 67 4b 40 7c mtvsrdd vs34,0,r9
29 10000c98: 02 16 5b 10 vextsd2q v2,v2
30 10000c9c: 20 00 80 4e blr
32 0000000010000cb0 <test_zero_extended_unsigned_load>:
33 10000cb0: 9b 18 44 7c lxvrwx vs34,r4,r3
34 10000cb4: 20 00 80 4e blr
44 unsigned long verbose
=0;
46 char initbuffer
[64] = {
47 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
48 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x80,
49 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
50 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0x90,
51 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
52 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xa0,
53 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
54 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xb0
57 vector
signed __int128 signed_expected
[16] = {
58 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000014131211},
59 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000015141312},
60 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000016151413},
61 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000017161514},
62 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000018171615},
63 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffff89181716},
64 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffff8a891817},
65 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffff8b8a8918},
66 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffff8c8b8a89},
67 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffff8d8c8b8a},
68 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffff8e8d8c8b},
69 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffff8f8e8d8c},
70 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffff808f8e8d},
71 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000021808f8e},
72 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x000000002221808f},
73 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000023222180}
76 vector
unsigned __int128 unsigned_expected
[16] = {
77 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x0000000014131211},
78 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x0000000015141312},
79 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x0000000016151413},
80 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x0000000017161514},
81 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x0000000018171615},
82 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x0000000089181716},
83 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x000000008a891817},
84 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x000000008b8a8918},
85 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x000000008c8b8a89},
86 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x000000008d8c8b8a},
87 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x000000008e8d8c8b},
88 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x000000008f8e8d8c},
89 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000808f8e8d},
90 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x0000000021808f8e},
91 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x000000002221808f},
92 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x0000000023222180}
95 __attribute__ ((noinline
))
96 vector
signed __int128
test_sign_extended_load(int RA
, signed int * RB
) {
97 return vec_xl_sext (RA
, RB
);
100 __attribute__ ((noinline
))
101 vector
unsigned __int128
test_zero_extended_unsigned_load(int RA
, unsigned int * RB
) {
102 return vec_xl_zext (RA
, RB
);
105 int main (int argc
, char *argv
[])
109 vector
signed __int128 signed_result_v
;
110 vector
unsigned __int128 unsigned_result_v
;
113 printf("%s %s\n", __DATE__
, __TIME__
);
116 memcpy(&buffer
, &initbuffer
, sizeof(buffer
));
119 printf("input buffer:\n");
120 for (int k
=0;k
<64;k
++) {
121 printf("%x ",initbuffer
[k
]);
122 if (k
&& (k
+1)%16==0) printf("\n");
124 printf("signed_expected:\n");
125 for (int k
=0;k
<ITERS
;k
++) {
126 printf("%llx ",signed_expected
[iteration
][0]>>64);
127 printf(" %llx \n",signed_expected
[iteration
][0]&0xffffffffffffffff);
130 printf("unsigned_expected:\n");
131 for (int k
=0;k
<ITERS
;k
++) {
132 printf("%llx ",signed_expected
[iteration
][0]>>64);
133 printf(" %llx \n",signed_expected
[iteration
][0]&0xffffffffffffffff);
138 for (iteration
= 0; iteration
< ITERS
; iteration
++ ) {
139 signed_result_v
= test_sign_extended_load (iteration
, (signed int*)buffer
);
140 if (signed_result_v
[0] != signed_expected
[iteration
][0] ) {
142 printf("Unexpected results from signed load. i=%d \n", iteration
);
143 printf("got: %llx ",signed_result_v
[0]>>64);
144 printf(" %llx \n",signed_result_v
[0]&0xffffffffffffffff);
145 printf("expected: %llx ",signed_expected
[iteration
][0]>>64);
146 printf(" %llx \n",signed_expected
[iteration
][0]&0xffffffffffffffff);
151 for (iteration
= 0; iteration
< ITERS
; iteration
++ ) {
152 unsigned_result_v
= test_zero_extended_unsigned_load (iteration
, (unsigned int*)buffer
);
153 if (unsigned_result_v
[0] != unsigned_expected
[iteration
][0]) {
155 printf("Unexpected results from unsigned load. i=%d \n", iteration
);
156 printf("got: %llx ",unsigned_result_v
[0]>>64);
157 printf(" %llx \n",unsigned_result_v
[0]&0xffffffffffffffff);
158 printf("expected: %llx ",unsigned_expected
[iteration
][0]>>64);
159 printf(" %llx \n",unsigned_expected
[iteration
][0]&0xffffffffffffffff);
165 printf("%d mismatches. \n",mismatch
);