[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx_mask-extract-runnable.c
blob9e257f5de7b1592b92b16d319bdada40a430b216
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 {\mvextractbm\M} 1 } } */
10 /* { dg-final { scan-assembler-times {\mvextracthm\M} 1 } } */
11 /* { dg-final { scan-assembler-times {\mvextractwm\M} 1 } } */
12 /* { dg-final { scan-assembler-times {\mvextractdm\M} 1 } } */
13 /* { dg-final { scan-assembler-times {\mvextractqm\M} 1 } } */
16 #define DEBUG 0
18 #if DEBUG
19 #include <stdio.h>
20 #include <stdlib.h>
21 #endif
22 #include <altivec.h>
24 void abort (void);
26 int main ()
28 int i, num_elements;
29 unsigned long long arg1;
31 vector unsigned char vbc_result_bi, vbc_expected_result_bi;
32 vector unsigned short vbc_result_hi, vbc_expected_result_hi;
33 vector unsigned int vbc_result_wi, vbc_expected_result_wi;
34 vector unsigned long long vbc_result_di, vbc_expected_result_di;
35 vector __uint128_t vbc_result_qi, vbc_expected_result_qi;
37 unsigned int result_wi, expected_result_wi;
38 unsigned long long result, expected_result;
39 const unsigned char mp=1;
40 vector unsigned char vbc_bi_src;
41 vector unsigned short vbc_hi_src;
42 vector unsigned int vbc_wi_src;
43 vector unsigned long long vbc_di_src;
44 vector __uint128_t vbc_qi_src;
46 /* vextractbm */
47 num_elements = 8;
48 vbc_bi_src[0] = 0xFF;
49 vbc_bi_src[1] = 0xFF;
50 vbc_bi_src[2] = 0x0;
51 vbc_bi_src[3] = 0x0;
52 vbc_bi_src[4] = 0x0;
53 vbc_bi_src[5] = 0x0;
54 vbc_bi_src[6] = 0xFF;
55 vbc_bi_src[7] = 0xFF;
56 vbc_bi_src[8] = 0xFF;
57 vbc_bi_src[9] = 0xFF;
58 vbc_bi_src[10] = 0xFF;
59 vbc_bi_src[11] = 0xFF;
60 vbc_bi_src[12] = 0xFF;
61 vbc_bi_src[13] = 0x0;
62 vbc_bi_src[14] = 0xFF;
63 vbc_bi_src[15] = 0xFF;
65 expected_result_wi = 0b1101111111000011;
67 result_wi = vec_extractm (vbc_bi_src);
69 if (result_wi != expected_result_wi) {
70 #if DEBUG
71 printf("ERROR: short vec_extractm(%d) ", vbc_bi_src);
72 printf("result %llu does not match expected result = %llu\n",
73 result, expected_result);
74 #else
75 abort();
76 #endif
79 /* vextracthm */
80 num_elements = 8;
81 vbc_hi_src[0] = 0xFFFF;
82 vbc_hi_src[1] = 0xFFFF;
83 vbc_hi_src[2] = 0x0;
84 vbc_hi_src[3] = 0x0;
85 vbc_hi_src[4] = 0x0;
86 vbc_hi_src[5] = 0x0;
87 vbc_hi_src[6] = 0xFFFF;
88 vbc_hi_src[7] = 0xFFFF;
90 expected_result_wi = 0b11000011;
92 result_wi = vec_extractm (vbc_hi_src);
94 if (result_wi != expected_result_wi) {
95 #if DEBUG
96 printf("ERROR: short vec_extractm(%d) ", vbc_hi_src);
97 printf("result %llu does not match expected result = %llu\n",
98 result, expected_result);
99 #else
100 abort();
101 #endif
104 /* vextractwm */
105 num_elements = 4;
106 vbc_wi_src[0] = 0xFFFFFFFF;
107 vbc_wi_src[1] = 0xFFFFFFFF;
108 vbc_wi_src[2] = 0x0;
109 vbc_wi_src[3] = 0x0;
111 expected_result_wi = 0b0011;
113 result_wi = vec_extractm (vbc_wi_src);
115 if (result_wi != expected_result_wi) {
116 #if DEBUG
117 printf("ERROR: word vec_extractm(%d) ", vbc_wi_src);
118 printf("result %llu does not match expected result = %llu\n",
119 result, expected_result);
120 #else
121 abort();
122 #endif
125 /* vextractdm */
126 num_elements = 2;
127 vbc_di_src[0] = 0xFFFFFFFFFFFFFFFF;
128 vbc_di_src[1] = 0xFFFFFFFFFFFFFFFF;
130 expected_result_wi = 0b11;
132 result_wi = vec_extractm (vbc_di_src);
134 if (result_wi != expected_result_wi) {
135 #if DEBUG
136 printf("ERROR: double vec_extractm(%lld) ", vbc_di_src);
137 printf("result %llu does not match expected result = %llu\n",
138 result, expected_result);
139 #else
140 abort();
141 #endif
144 /* vextractqm */
145 num_elements = 1;
146 vbc_qi_src[0] = 0x1;
147 vbc_qi_src[0] = vbc_qi_src[0] << 127;
149 expected_result_wi = 1;
151 result_wi = vec_extractm (vbc_qi_src);
153 if (result_wi != expected_result_wi) {
154 #if DEBUG
155 printf("ERROR: quad vec_extractm(arg) ");
156 printf("result 0x%x does not match expected result = 0x%x\n",
157 result, expected_result);
158 #else
159 abort();
160 #endif
163 return 0;