[RS6000] Replace -mcpu with -mdejagnu-cpu
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx_mask-count-runnable.c
blob6aa165c675cd5119874f98d0c725910fd1ff525e
1 /* { dg-do run { target { power10_hw } } } */
2 /* { dg-do link { target { ! power10_hw } } } */
3 /* { dg-options "-mdejagnu-cpu=power10 -O2" } */
4 /* { dg-require-effective-target { int128 && power10_ok } } */
6 /* Check that the expected 128-bit instructions are generated if the processor
7 supports the 128-bit integer instructions. */
8 /* { dg-final { scan-assembler-times {\mvcntmbb\M} 1 } } */
9 /* { dg-final { scan-assembler-times {\mvcntmbh\M} 1 } } */
10 /* { dg-final { scan-assembler-times {\mvcntmbw\M} 1 } } */
11 /* { dg-final { scan-assembler-times {\mvcntmbd\M} 1 } } */
13 #define DEBUG 0
15 #if DEBUG
16 #include <stdio.h>
17 #include <stdlib.h>
18 #endif
19 #include <altivec.h>
21 void abort (void);
23 int main ()
25 int i, num_elements;
26 unsigned long long arg1;
28 vector unsigned char vbc_result_bi, vbc_expected_result_bi;
29 vector unsigned short vbc_result_hi, vbc_expected_result_hi;
30 vector unsigned int vbc_result_wi, vbc_expected_result_wi;
31 vector unsigned long long vbc_result_di, vbc_expected_result_di;
32 vector __uint128_t vbc_result_qi, vbc_expected_result_qi;
34 unsigned int result_wi, expected_result_wi;
35 unsigned long long result, expected_result;
36 const unsigned char mp=1;
37 vector unsigned char vbc_bi_src;
38 vector unsigned short vbc_hi_src;
39 vector unsigned int vbc_wi_src;
40 vector unsigned long long vbc_di_src;
41 vector __uint128_t vbc_qi_src;
43 /* vcntmbb */
44 num_elements = 16;
45 vbc_bi_src[0] = 0xFF;
46 vbc_bi_src[1] = 0xFF;
47 vbc_bi_src[2] = 0x0;
48 vbc_bi_src[3] = 0x0;
49 vbc_bi_src[4] = 0x0;
50 vbc_bi_src[5] = 0x0;
51 vbc_bi_src[6] = 0xFF;
52 vbc_bi_src[7] = 0xFF;
53 vbc_bi_src[8] = 0x0;
54 vbc_bi_src[9] = 0x0;
55 vbc_bi_src[10] = 0x0;
56 vbc_bi_src[11] = 0x0;
57 vbc_bi_src[12] = 0x0;
58 vbc_bi_src[13] = 0xFF;
59 vbc_bi_src[14] = 0xFF;
60 vbc_bi_src[15] = 0xFF;
62 expected_result = 7;
64 result = vec_cntm (vbc_bi_src, 1);
65 /* Note count is put in bits[0:7], IBM numbering, of the 64-bit result */
66 result = result >> (64-8);
68 if (result != expected_result) {
69 #if DEBUG
70 printf("ERROR: char vec_cntm(arg) ");
71 printf("count %llu does not match expected count = %llu\n",
72 result, expected_result);
73 #else
74 abort();
75 #endif
78 /* vcntmhb */
79 num_elements = 8;
80 vbc_hi_src[0] = 0xFFFF;
81 vbc_hi_src[1] = 0xFFFF;
82 vbc_hi_src[2] = 0x0;
83 vbc_hi_src[3] = 0x0;
84 vbc_hi_src[4] = 0x0;
85 vbc_hi_src[5] = 0x0;
86 vbc_hi_src[6] = 0xFFFF;
87 vbc_hi_src[7] = 0xFFFF;
89 expected_result = 4;
91 result = vec_cntm (vbc_hi_src, 1);
92 /* Note count is put in bits[0:6], IBM numbering, of the 64-bit result */
93 result = result >> (64-7);
95 if (result != expected_result) {
96 #if DEBUG
97 printf("ERROR: short vec_cntm(arg) ");
98 printf("count %llu does not match expected count = %llu\n",
99 result, expected_result);
100 #else
101 abort();
102 #endif
105 /* vcntmwb */
106 num_elements = 4;
107 vbc_wi_src[0] = 0xFFFFFFFF;
108 vbc_wi_src[1] = 0xFFFFFFFF;
109 vbc_wi_src[2] = 0x0;
110 vbc_wi_src[3] = 0x0;
112 expected_result = 2;
114 result = vec_cntm (vbc_wi_src, 1);
115 /* Note count is put in bits[0:5], IBM numbering, of the 64-bit result */
116 result = result >> (64-6);
118 if (result != expected_result) {
119 #if DEBUG
120 printf("ERROR: word vec_cntm(arg) ");
121 printf("count %llu does not match expected count = %llu\n",
122 result, expected_result);
123 #else
124 abort();
125 #endif
128 /* vcntmdb */
129 num_elements = 2;
130 vbc_di_src[0] = 0xFFFFFFFFFFFFFFFFULL;
131 vbc_di_src[1] = 0xFFFFFFFFFFFFFFFFULL;
133 expected_result = 2;
135 result = vec_cntm (vbc_di_src, 1);
136 /* Note count is put in bits[0:4], IBM numbering, of the 64-bit result */
137 result = result >> (64-5);
139 if (result != expected_result) {
140 #if DEBUG
141 printf("ERROR: double vec_cntm(arg) ");
142 printf("count %llu does not match expected count = %llu\n",
143 result, expected_result);
144 #else
145 abort();
146 #endif
149 return 0;