Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/lsbb-runnable.c

raw
1 /*
2 Test the least significant bit by byte instruction
3 xvtlsbb BF,XB
4 Using the builtins
5 int vec_test_lsbb_all_zeros (vector unsigned char);
6 int vec_test_lsbb_all_ones (vector unsigned char);
7 */
8
9 /* { dg-do run { target { power10_hw } } } */
10 /* { dg-do link { target { ! power10_hw } } } */
11 /* { dg-require-effective-target power10_ok } */
12 /* { dg-options "-fno-inline -mdejagnu-cpu=power10 -O2" } */
13
14 #include <altivec.h>
15 #include <stdio.h>
16
17 void abort (void);
18
19 #define ITERS 7
20 vector signed char input_svec[ITERS] = {
21 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
22 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
23 {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
24 {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},
25 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
26 {0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe},
27 {0xfe, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9}
28 };
29
30 vector unsigned char input_uvec[ITERS] = {
31 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
32 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
33 {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
34 {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},
35 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
36 {0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe},
37 {0xfe, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9}
38 };
39
40 vector bool char input_bvec[ITERS] = {
41 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
42 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
43 {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
44 {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},
45 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
46 {0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe},
47 {0xfe, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9}
48 };
49
50 int expected_allzeros_results[ITERS] = {1, 0, 0, 0, 0, 1, 0};
51 int expected_allones_results[ITERS] = {0, 1, 0, 0, 1, 0, 0};
52
53 int test_for_zeros_uc(vector unsigned char vuc) {
54 return vec_test_lsbb_all_zeros(vuc);
55 }
56
57 int test_for_zeros_sc(vector signed char vsc) {
58 return vec_test_lsbb_all_zeros(vsc);
59 }
60
61 int test_for_zeros_bc(vector bool char vbc) {
62 return vec_test_lsbb_all_zeros(vbc);
63 }
64
65 int test_for_ones_sc(vector signed char vsc) {
66 return vec_test_lsbb_all_ones(vsc);
67 }
68
69 int test_for_ones_uc(vector unsigned char vuc) {
70 return vec_test_lsbb_all_ones(vuc);
71 }
72
73 int test_for_ones_bc(vector bool char vbc) {
74 return vec_test_lsbb_all_ones(vbc);
75 }
76
77 int main ()
78 {
79 int allzeros, allones;
80 int iter;
81 int failcount=0;
82 vector signed char srcvec_sc;
83 vector unsigned char srcvec_uc;
84 vector bool char srcvec_bc;
85
86 /* Signed type tests. */
87 for (iter=0;iter<ITERS;iter++) {
88 srcvec_sc = input_svec[iter];
89 allzeros = test_for_zeros_sc(srcvec_sc);
90 allones = test_for_ones_sc(srcvec_sc);
91 if (allzeros != expected_allzeros_results[iter]) {
92 printf("fail on allzero signed char check. iter %d, result was %d \n",
93 iter, allzeros);
94 failcount++;
95 }
96 if (allones != expected_allones_results[iter]) {
97 printf("fail on allones signed char check. iter %d, result was %d \n",
98 iter, allones);
99 failcount++;
100 }
101 }
102
103 if (failcount)
104 abort();
105
106 /* Unsigned type tests. */
107 for (iter=0;iter<ITERS;iter++) {
108 srcvec_uc = input_uvec[iter];
109 allzeros = test_for_zeros_uc(srcvec_uc);
110 allones = test_for_ones_uc(srcvec_uc);
111 if (allzeros != expected_allzeros_results[iter]) {
112 printf("fail on allzero unsigned char check. iter %d, result was %d \n",
113 iter, allzeros);
114 failcount++;
115 }
116 if (allones != expected_allones_results[iter]) {
117 printf("fail on allones unsigned char check. iter %d, result was %d \n",
118 iter, allones);
119 failcount++;
120 }
121 }
122
123 if (failcount)
124 abort();
125
126 /* Bool char type tests. */
127 for (iter=0;iter<ITERS;iter++) {
128 srcvec_bc = input_bvec[iter];
129 allzeros = test_for_zeros_bc(srcvec_bc);
130 allones = test_for_ones_bc(srcvec_bc);
131 if (allzeros != expected_allzeros_results[iter]) {
132 printf("fail on allzero bool char check. iter %d, result was %d \n",
133 iter, allzeros);
134 failcount++;
135 }
136 if (allones != expected_allones_results[iter]) {
137 printf("fail on allones bool char check. iter %d, result was %d \n",
138 iter, allones);
139 failcount++;
140 }
141 }
142
143 if (failcount)
144 abort();
145
146
147 return 0;
148 }
149