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
10 do_cntlzdm (unsigned long long int source, unsigned long long int mask)
11 {
12 return __builtin_cntlzdm (source, mask);
13 }
14
15 int main (int argc, char *argv [])
16 {
17 unsigned long long int sources [4], masks [4];
18 unsigned long long int intermediates [4][4] = {
19 /* sources[0] with each of masks [0 .. 3] */
20 { 0x0000a5f0ll, 0x00007e3cll, 0x000050ecll, 0x0000af73ll },
21 /* sources[1] with each of masks [0 .. 3] */
22 { 0x00007e3cll, 0x0000a5f0ll, 0x0000ec50ll, 0x000073afll },
23 /* sources[2] with each of masks [0 .. 3] */
24 { 0x00003ca5ll, 0x0000f07ell, 0x0000c50ell, 0x00003af7ll },
25 /* sources[3] with each of masks [0 .. 3] */
26 { 0x00005a0fll, 0x0000e7c3ll, 0x0000af73ll, 0x000050ecll },
27 };
28 unsigned long long int results [4][4] = {
29 { 0, 1, 1, 0 },
30 { 1, 0, 0, 1 },
31 { 2, 0, 0, 2 },
32 { 1, 0, 0, 1 },
33 };
34
35 sources[0] = 0xa5f07e3cll;
36 sources[1] = 0x7e3ca5f0ll;
37 sources[2] = 0x3ca5f07ell;
38 sources[3] = 0x5a0fe7c3ll;
39
40 masks[0] = 0xffff0000ll;
41 masks[1] = 0x0000ffffll;
42 masks[2] = 0x0f0f0f0fll;
43 masks[3] = 0xf0f0f0f0ll;
44
45 unsigned long long int result;
46
47 for (int i = 0; i < 4; i++)
48 {
49 for (int j = 0; j < 4; j++)
50 {
51 if (do_cntlzdm (sources[i], masks[j]) != results [i][j])
52 abort ();
53 }
54 }
55
56 return 0;
57 }