[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx_mask-expand-runnable.c
blob2c49814e0f7525f99833e0595516dbf2d01e0039
1 /* { dg-do run { target { power10_hw } } } */
2 /* { dg-do link { target { ! power10_hw } } } */
3 /* { dg-options "-mdejagnu-cpu=power10 -O2 -save-temps" } */
4 /* { dg-require-effective-target power10_ok } */
5 /* { dg-require-effective-target int128 } */
7 /* Check that the expected 128-bit instructions are generated if the processor
8 supports the 128-bit integer instructions. */
9 /* { dg-final { scan-assembler-times {\mvexpandbm\M} 1 } } */
10 /* { dg-final { scan-assembler-times {\mvexpandhm\M} 1 } } */
11 /* { dg-final { scan-assembler-times {\mvexpandwm\M} 1 } } */
12 /* { dg-final { scan-assembler-times {\mvexpanddm\M} 1 } } */
13 /* { dg-final { scan-assembler-times {\mvexpandqm\M} 1 } } */
15 #define DEBUG 0
17 #if DEBUG
18 #include <stdio.h>
19 #include <stdlib.h>
20 #endif
21 #include <altivec.h>
23 void abort (void);
25 int main ()
27 int i, num_elements;
28 unsigned long long arg1;
30 vector unsigned char vbc_result_bi, vbc_expected_result_bi;
31 vector unsigned short vbc_result_hi, vbc_expected_result_hi;
32 vector unsigned int vbc_result_wi, vbc_expected_result_wi;
33 vector unsigned long long vbc_result_di, vbc_expected_result_di;
34 vector __uint128_t vbc_result_qi, vbc_expected_result_qi;
36 unsigned int result_wi, expected_result_wi;
37 unsigned long long result, expected_result;
38 const unsigned char mp=1;
39 vector unsigned char vbc_bi_src;
40 vector unsigned short vbc_hi_src;
41 vector unsigned int vbc_wi_src;
42 vector unsigned long long vbc_di_src;
43 vector __uint128_t vbc_qi_src;
45 /* vexpandbm */
46 num_elements = 16;
47 vbc_bi_src[0] = 0xFF;
48 vbc_bi_src[1] = 0xFF;
49 vbc_bi_src[2] = 0x0;
50 vbc_bi_src[3] = 0x0;
51 vbc_bi_src[4] = 0x0;
52 vbc_bi_src[5] = 0x0;
53 vbc_bi_src[6] = 0xFF;
54 vbc_bi_src[7] = 0xFF;
55 vbc_bi_src[8] = 0x0;
56 vbc_bi_src[9] = 0x0;
57 vbc_bi_src[10] = 0x0;
58 vbc_bi_src[11] = 0x0;
59 vbc_bi_src[12] = 0x0;
60 vbc_bi_src[13] = 0xFF;
61 vbc_bi_src[14] = 0xFF;
62 vbc_bi_src[15] = 0xFF;
64 vbc_expected_result_bi[0] = 0xFF;
65 vbc_expected_result_bi[1] = 0xFF;
66 vbc_expected_result_bi[2] = 0x0;
67 vbc_expected_result_bi[3] = 0x0;
68 vbc_expected_result_bi[4] = 0x0;
69 vbc_expected_result_bi[5] = 0x0;
70 vbc_expected_result_bi[6] = 0xFF;
71 vbc_expected_result_bi[7] = 0xFF;
72 vbc_expected_result_bi[8] = 0x0;
73 vbc_expected_result_bi[9] = 0x0;
74 vbc_expected_result_bi[10] = 0x0;
75 vbc_expected_result_bi[11] = 0x0;
76 vbc_expected_result_bi[12] = 0x0;
77 vbc_expected_result_bi[13] = 0xFF;
78 vbc_expected_result_bi[14] = 0xFF;
79 vbc_expected_result_bi[15] = 0xFF;
81 vbc_result_bi = vec_expandm (vbc_bi_src);
83 for (i = 0; i<num_elements; i++) {
84 if (vbc_result_bi[i] != vbc_expected_result_bi[i]) {
85 #if DEBUG
86 printf("ERROR: char vec_expandm(arg) ");
87 printf("element %d, 0x%x does not match expected value = 0x%x\n",
88 i, vbc_result_bi[i], vbc_expected_result_bi[i]);
89 #else
90 abort();
91 #endif
95 /* vexpandhm */
96 num_elements = 8;
97 vbc_hi_src[0] = 0x0;
98 vbc_hi_src[1] = 0xFFFF;
99 vbc_hi_src[2] = 0x0;
100 vbc_hi_src[3] = 0xFFFF;
101 vbc_hi_src[4] = 0x0;
102 vbc_hi_src[5] = 0x0;
103 vbc_hi_src[6] = 0xFFFF;
104 vbc_hi_src[7] = 0xFFFF;
106 vbc_expected_result_hi[0] = 0x0;
107 vbc_expected_result_hi[1] = 0xFFFF;
108 vbc_expected_result_hi[2] = 0x0;
109 vbc_expected_result_hi[3] = 0xFFFF;
110 vbc_expected_result_hi[4] = 0x0;
111 vbc_expected_result_hi[5] = 0x0;
112 vbc_expected_result_hi[6] = 0xFFFF;
113 vbc_expected_result_hi[7] = 0xFFFF;
115 vbc_result_hi = vec_expandm (vbc_hi_src);
117 for (i = 0; i<num_elements; i++) {
118 if (vbc_result_hi[i] != vbc_expected_result_hi[i]) {
119 #if DEBUG
120 printf("ERROR: short vec_expandm(arg) ");
121 printf("element %d, 0x%x does not match expected value = 0x%x\n",
122 i, vbc_result_hi[i], vbc_expected_result_hi[i]);
123 #else
124 abort();
125 #endif
129 /* vexpandwm */
130 num_elements = 4;
131 vbc_wi_src[0] = 0x0;
132 vbc_wi_src[1] = 0xFFFFFFFF;
133 vbc_wi_src[2] = 0x0;
134 vbc_wi_src[3] = 0xFFFFFFFF;
136 vbc_expected_result_wi[0] = 0x0;
137 vbc_expected_result_wi[1] = 0xFFFFFFFF;
138 vbc_expected_result_wi[2] = 0x0;
139 vbc_expected_result_wi[3] = 0xFFFFFFFF;
141 vbc_result_wi = vec_expandm (vbc_wi_src);
143 for (i = 0; i<num_elements; i++) {
144 if (vbc_result_wi[i] != vbc_expected_result_wi[i]) {
145 #if DEBUG
146 printf("ERROR: int vec_expandm(arg) ");
147 printf("element %d, 0x%x does not match expected value = 0x%x\n",
148 i, vbc_result_wi[i], vbc_expected_result_wi[i]);
149 #else
150 abort();
151 #endif
155 /* vexpanddm */
156 num_elements = 2;
157 vbc_di_src[0] = 0x0;
158 vbc_di_src[1] = 0xFFFFFFFFFFFFFFFFULL;
160 vbc_expected_result_di[0] = 0x0;
161 vbc_expected_result_di[1] = 0xFFFFFFFFFFFFFFFFULL;
163 vbc_result_di = vec_expandm (vbc_di_src);
165 for (i = 0; i<num_elements; i++) {
166 if (vbc_result_di[i] != vbc_expected_result_di[i]) {
167 #if DEBUG
168 printf("ERROR: double vec_expandm(arg) ");
169 printf("element %d, 0x%llx does not match expected value = 0x%llx\n",
170 i, vbc_result_di[i], vbc_expected_result_di[i]);
171 #else
172 abort();
173 #endif
177 /* vexpandqm */
178 num_elements = 1;
179 vbc_qi_src[0] = 0x0;
181 vbc_expected_result_qi[0] = 0x0;
183 vbc_result_qi = vec_expandm (vbc_qi_src);
185 if (vbc_result_qi[0] != vbc_expected_result_qi[0]) {
186 #if DEBUG
187 printf("ERROR: quad vec_expandm(arg) ");
188 printf("element %d, 0x%x does not match expected value = 0x%x\n",
189 0, vbc_result_qi[i], vbc_expected_result_qi[i]);
190 #else
191 abort();
192 #endif
195 return 0;