[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx_mask-count-runnable.c
blob1ea2d65abf9a73563be371d92671ca3c25571196
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 {\mvcntmbb\M} 1 } } */
10 /* { dg-final { scan-assembler-times {\mvcntmbh\M} 1 } } */
11 /* { dg-final { scan-assembler-times {\mvcntmbw\M} 1 } } */
12 /* { dg-final { scan-assembler-times {\mvcntmbd\M} 1 } } */
14 #define DEBUG 0
16 #if DEBUG
17 #include <stdio.h>
18 #include <stdlib.h>
19 #endif
20 #include <altivec.h>
22 void abort (void);
24 int main ()
26 int i, num_elements;
27 unsigned long long arg1;
29 vector unsigned char vbc_result_bi, vbc_expected_result_bi;
30 vector unsigned short vbc_result_hi, vbc_expected_result_hi;
31 vector unsigned int vbc_result_wi, vbc_expected_result_wi;
32 vector unsigned long long vbc_result_di, vbc_expected_result_di;
33 vector __uint128_t vbc_result_qi, vbc_expected_result_qi;
35 unsigned int result_wi, expected_result_wi;
36 unsigned long long result, expected_result;
37 const unsigned char mp=1;
38 vector unsigned char vbc_bi_src;
39 vector unsigned short vbc_hi_src;
40 vector unsigned int vbc_wi_src;
41 vector unsigned long long vbc_di_src;
42 vector __uint128_t vbc_qi_src;
44 /* vcntmbb */
45 num_elements = 16;
46 vbc_bi_src[0] = 0xFF;
47 vbc_bi_src[1] = 0xFF;
48 vbc_bi_src[2] = 0x0;
49 vbc_bi_src[3] = 0x0;
50 vbc_bi_src[4] = 0x0;
51 vbc_bi_src[5] = 0x0;
52 vbc_bi_src[6] = 0xFF;
53 vbc_bi_src[7] = 0xFF;
54 vbc_bi_src[8] = 0x0;
55 vbc_bi_src[9] = 0x0;
56 vbc_bi_src[10] = 0x0;
57 vbc_bi_src[11] = 0x0;
58 vbc_bi_src[12] = 0x0;
59 vbc_bi_src[13] = 0xFF;
60 vbc_bi_src[14] = 0xFF;
61 vbc_bi_src[15] = 0xFF;
63 expected_result = 7;
65 result = vec_cntm (vbc_bi_src, 1);
66 /* Note count is put in bits[0:7], IBM numbering, of the 64-bit result */
67 result = result >> (64-8);
69 if (result != expected_result) {
70 #if DEBUG
71 printf("ERROR: char vec_cntm(arg) ");
72 printf("count %llu does not match expected count = %llu\n",
73 result, expected_result);
74 #else
75 abort();
76 #endif
79 /* vcntmhb */
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 = 4;
92 result = vec_cntm (vbc_hi_src, 1);
93 /* Note count is put in bits[0:6], IBM numbering, of the 64-bit result */
94 result = result >> (64-7);
96 if (result != expected_result) {
97 #if DEBUG
98 printf("ERROR: short vec_cntm(arg) ");
99 printf("count %llu does not match expected count = %llu\n",
100 result, expected_result);
101 #else
102 abort();
103 #endif
106 /* vcntmwb */
107 num_elements = 4;
108 vbc_wi_src[0] = 0xFFFFFFFF;
109 vbc_wi_src[1] = 0xFFFFFFFF;
110 vbc_wi_src[2] = 0x0;
111 vbc_wi_src[3] = 0x0;
113 expected_result = 2;
115 result = vec_cntm (vbc_wi_src, 1);
116 /* Note count is put in bits[0:5], IBM numbering, of the 64-bit result */
117 result = result >> (64-6);
119 if (result != expected_result) {
120 #if DEBUG
121 printf("ERROR: word vec_cntm(arg) ");
122 printf("count %llu does not match expected count = %llu\n",
123 result, expected_result);
124 #else
125 abort();
126 #endif
129 /* vcntmdb */
130 num_elements = 2;
131 vbc_di_src[0] = 0xFFFFFFFFFFFFFFFFULL;
132 vbc_di_src[1] = 0xFFFFFFFFFFFFFFFFULL;
134 expected_result = 2;
136 result = vec_cntm (vbc_di_src, 1);
137 /* Note count is put in bits[0:4], IBM numbering, of the 64-bit result */
138 result = result >> (64-5);
140 if (result != expected_result) {
141 #if DEBUG
142 printf("ERROR: double vec_cntm(arg) ");
143 printf("count %llu does not match expected count = %llu\n",
144 result, expected_result);
145 #else
146 abort();
147 #endif
150 return 0;