1 /* { dg-do run { target { power10_hw } } } */
2 /* { dg-do link { target { ! power10_hw } } } */
3 /* { dg-require-effective-target power10_ok } */
4 /* { dg-require-effective-target lp64 } */
5 /* { dg-options "-mdejagnu-cpu=power10" } */
6
7 extern void abort (void);
8
9 unsigned long long int
do_cnttzdm(unsigned long long int source,unsigned long long int mask)10 do_cnttzdm (unsigned long long int source, unsigned long long int mask) {
11 return __builtin_cnttzdm (source, mask);
12 }
13
main(int argc,char * argv[])14 int main (int argc, char *argv [])
15 {
16 unsigned long long int sources [4], masks [4];
17 unsigned long long int intermediates [4][4] = {
18 /* sources[0] with each of masks [0 .. 3] */
19 { 0x0000a5f0ll, 0x00007e3cll, 0x000050ecll, 0x0000af73ll },
20 /* sources[1] with each of masks [0 .. 3] */
21 { 0x00007e3cll, 0x0000a5f0ll, 0x0000ec50ll, 0x000073afll },
22 /* sources[2] with each of masks [0 .. 3] */
23 { 0x00003ca5ll, 0x0000f07ell, 0x0000c50ell, 0x00003af7ll },
24 /* sources[3] with each of masks [0 .. 3] */
25 { 0x00005a0fll, 0x0000e7c3ll, 0x0000af73ll, 0x000050ecll },
26 };
27 unsigned long long int results [4][4] = {
28 { 4, 2, 2, 0 },
29 { 2, 4, 4, 0 },
30 { 0, 1, 1, 0 },
31 { 0, 0, 0, 2 },
32 };
33
34 sources[0] = 0xa5f07e3cll;
35 sources[1] = 0x7e3ca5f0ll;
36 sources[2] = 0x3ca5f07ell;
37 sources[3] = 0x5a0fe7c3ll;
38
39 masks[0] = 0xffff0000ll;
40 masks[1] = 0x0000ffffll;
41 masks[2] = 0x0f0f0f0fll;
42 masks[3] = 0xf0f0f0f0ll;
43
44 for (int i = 0; i < 4; i++)
45 {
46 for (int j = 0; j < 4; j++)
47 {
48 if (do_cnttzdm (sources[i], masks[j]) != results [i][j])
49 abort ();
50 }
51 }
52
53 return 0;
54 }
55