[RS6000] Don't be too clever with dg-do run and dg-do compile
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-load-element-extend-longlong.c
blob405b4245f8e2021b84c4de8b698f0c037bfa3e18
1 /*
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 } */
9 /* { dg-options "-mdejagnu-cpu=power10 -O3 -save-temps" } */
11 /* At time of writing, we also geenerate a .constrprop copy
12 of the function, so our instruction hit count is
13 twice of what we would otherwise expect. */
14 /* { dg-final { scan-assembler-times {\mlxvrdx\M} 4 } } */
15 /* { dg-final { scan-assembler-times {\mlvdx\M} 0 } } */
17 #define NUM_VEC_ELEMS 2
18 #define ITERS 16
21 Codegen at time of writing uses lxvrdx for both sign and
22 zero extend tests. The sign extended test also uses
23 mfvsr*d, mtvsrdd, vextsd2q.
25 0000000010000c90 <test_sign_extended_load>:
26 10000c90: da 18 04 7c lxvrdx vs0,r4,r3
27 10000c94: 66 00 0b 7c mfvsrd r11,vs0
28 10000c98: 66 02 0a 7c mfvsrld r10,vs0
29 10000c9c: 67 53 40 7c mtvsrdd vs34,0,r10
30 10000ca0: 02 16 5b 10 vextsd2q v2,v2
31 10000ca4: 20 00 80 4e blr
33 0000000010000cc0 <test_zero_extended_unsigned_load>:
34 10000cc0: db 18 44 7c lxvrdx vs34,r4,r3
35 10000cc4: 20 00 80 4e blr
38 #include <altivec.h>
39 #include <stdio.h>
40 #include <inttypes.h>
41 #include <string.h>
42 #include <stdlib.h>
44 long long buffer[8];
45 unsigned long verbose=0;
47 char initbuffer[64] = {
48 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
49 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x80,
50 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
51 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0x90,
52 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
53 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xa0,
54 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
55 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xb0
58 vector signed __int128 signed_expected[16] = {
59 { (__int128) 0x0000000000000000 << 64 | (__int128) 0x1817161514131211},
60 { (__int128) 0xffffffffffffffff << 64 | (__int128) 0x8918171615141312},
61 { (__int128) 0xffffffffffffffff << 64 | (__int128) 0x8a89181716151413},
62 { (__int128) 0xffffffffffffffff << 64 | (__int128) 0x8b8a891817161514},
63 { (__int128) 0xffffffffffffffff << 64 | (__int128) 0x8c8b8a8918171615},
64 { (__int128) 0xffffffffffffffff << 64 | (__int128) 0x8d8c8b8a89181716},
65 { (__int128) 0xffffffffffffffff << 64 | (__int128) 0x8e8d8c8b8a891817},
66 { (__int128) 0xffffffffffffffff << 64 | (__int128) 0x8f8e8d8c8b8a8918},
67 { (__int128) 0xffffffffffffffff << 64 | (__int128) 0x808f8e8d8c8b8a89},
68 { (__int128) 0x0000000000000000 << 64 | (__int128) 0x21808f8e8d8c8b8a},
69 { (__int128) 0x0000000000000000 << 64 | (__int128) 0x2221808f8e8d8c8b},
70 { (__int128) 0x0000000000000000 << 64 | (__int128) 0x232221808f8e8d8c},
71 { (__int128) 0x0000000000000000 << 64 | (__int128) 0x24232221808f8e8d},
72 { (__int128) 0x0000000000000000 << 64 | (__int128) 0x2524232221808f8e},
73 { (__int128) 0x0000000000000000 << 64 | (__int128) 0x262524232221808f},
74 { (__int128) 0x0000000000000000 << 64 | (__int128) 0x2726252423222180}
77 vector unsigned __int128 unsigned_expected[16] = {
78 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x1817161514131211},
79 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x8918171615141312},
80 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x8a89181716151413},
81 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x8b8a891817161514},
82 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x8c8b8a8918171615},
83 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x8d8c8b8a89181716},
84 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x8e8d8c8b8a891817},
85 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x8f8e8d8c8b8a8918},
86 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x808f8e8d8c8b8a89},
87 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x21808f8e8d8c8b8a},
88 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x2221808f8e8d8c8b},
89 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x232221808f8e8d8c},
90 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x24232221808f8e8d},
91 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x2524232221808f8e},
92 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x262524232221808f},
93 { (unsigned __int128) 0x0000000000000000 << 64 | (unsigned __int128) 0x2726252423222180}
96 __attribute__ ((noinline))
97 vector signed __int128 test_sign_extended_load(int RA, signed long long * RB) {
98 return vec_xl_sext (RA, RB);
101 __attribute__ ((noinline))
102 vector unsigned __int128 test_zero_extended_unsigned_load(int RA, unsigned long long * RB) {
103 return vec_xl_zext (RA, RB);
106 int main (int argc, char *argv [])
108 int iteration=0;
109 int mismatch=0;
110 vector signed __int128 signed_result_v;
111 vector unsigned __int128 unsigned_result_v;
112 #if VERBOSE
113 verbose=1;
114 printf("%s %s\n", __DATE__, __TIME__);
115 #endif
117 memcpy(&buffer, &initbuffer, sizeof(buffer));
119 if (verbose) {
120 printf("input buffer:\n");
121 for (int k=0;k<64;k++) {
122 printf("%x ",initbuffer[k]);
123 if (k && (k+1)%16==0) printf("\n");
125 printf("signed_expected:\n");
126 for (int k=0;k<ITERS;k++) {
127 printf("%llx ",signed_expected[iteration][0]>>64);
128 printf(" %llx \n",signed_expected[iteration][0]&0xffffffffffffffff);
129 printf("\n");
131 printf("unsigned_expected:\n");
132 for (int k=0;k<ITERS;k++) {
133 printf("%llx ",signed_expected[iteration][0]>>64);
134 printf(" %llx \n",signed_expected[iteration][0]&0xffffffffffffffff);
135 printf("\n");
139 for (iteration = 0; iteration < ITERS ; iteration++ ) {
140 signed_result_v = test_sign_extended_load (iteration, (signed long long*)buffer);
141 if (signed_result_v[0] != signed_expected[iteration][0] ) {
142 mismatch++;
143 printf("Unexpected results from signed load. i=%d \n", iteration);
144 printf("got: %llx ",signed_result_v[0]>>64);
145 printf(" %llx \n",signed_result_v[0]&0xffffffffffffffff);
146 printf("expected: %llx ",signed_expected[iteration][0]>>64);
147 printf(" %llx \n",signed_expected[iteration][0]&0xffffffffffffffff);
148 fflush(stdout);
152 for (iteration = 0; iteration < ITERS ; iteration++ ) {
153 unsigned_result_v = test_zero_extended_unsigned_load (iteration, (unsigned long long*)buffer);
154 if (unsigned_result_v[0] != unsigned_expected[iteration][0]) {
155 mismatch++;
156 printf("Unexpected results from unsigned load. i=%d \n", iteration);
157 printf("got: %llx ",unsigned_result_v[0]>>64);
158 printf(" %llx \n",unsigned_result_v[0]&0xffffffffffffffff);
159 printf("expected: %llx ",unsigned_expected[iteration][0]>>64);
160 printf(" %llx \n",unsigned_expected[iteration][0]&0xffffffffffffffff);
161 fflush(stdout);
165 if (mismatch) {
166 printf("%d mismatches. \n",mismatch);
167 abort();
169 return 0;