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 {\mlxvrhx\M} 2 } } */
18 #define NUM_VEC_ELEMS 8
22 Codegen at time of writing uses lxvrhx for the zero
23 extension test and lhax,mtvsrdd,vextsd2q for the
26 0000000010001810 <test_sign_extended_load>:
27 10001810: ae 1a 24 7d lhax r9,r4,r3
28 10001814: 67 4b 40 7c mtvsrdd vs34,0,r9
29 10001818: 02 16 5b 10 vextsd2q v2,v2
30 1000181c: 20 00 80 4e blr
32 0000000010001830 <test_zero_extended_unsigned_load>:
33 10001830: 5b 18 44 7c lxvrhx vs34,r4,r3
34 10001834: 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
) 0x0000000000001211},
59 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000000001312},
60 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000000001413},
61 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000000001514},
62 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000000001615},
63 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000000001716},
64 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000000001817},
65 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffffffff8918},
66 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffffffff8a89},
67 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffffffff8b8a},
68 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffffffff8c8b},
69 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffffffff8d8c},
70 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffffffff8e8d},
71 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffffffff8f8e},
72 { (__int128
) 0xffffffffffffffff << 64 | (__int128
) 0xffffffffffff808f},
73 { (__int128
) 0x0000000000000000 << 64 | (__int128
) 0x0000000000002180}
76 vector
unsigned __int128 unsigned_expected
[16] = {
77 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000001211},
78 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000001312},
79 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000001413},
80 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000001514},
81 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000001615},
82 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000001716},
83 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000001817},
84 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000008918},
85 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000008a89},
86 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000008b8a},
87 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000008c8b},
88 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000008d8c},
89 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000008e8d},
90 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000008f8e},
91 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x0000000000000808f},
92 { (unsigned __int128
) 0x0000000000000000 << 64 | (unsigned __int128
) 0x00000000000002180}
95 __attribute__ ((noinline
))
96 vector
signed __int128
test_sign_extended_load(int RA
, signed short * RB
) {
97 return vec_xl_sext (RA
, RB
);
100 __attribute__ ((noinline
))
101 vector
unsigned __int128
test_zero_extended_unsigned_load(int RA
, unsigned short * 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 short*)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 short*)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
);