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 char input_vec[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 int expected_allzeros_results[ITERS] = {1, 0, 0, 0, 0, 1, 0};
31 int expected_allones_results[ITERS] = {0, 1, 0, 0, 1, 0, 0};
32
33 int test_for_zeros(vector char vc) {
34 return vec_test_lsbb_all_zeros(vc);
35 }
36
37 int test_for_ones(vector char vc) {
38 return vec_test_lsbb_all_ones(vc);
39 }
40
41 int main ()
42 {
43 int allzeros,allones;
44 int iter;
45 int failcount=0;
46 vector char srcvec;
47
48 for (iter=0;iter<ITERS;iter++) {
49 srcvec = input_vec[iter];
50 allzeros = test_for_zeros(srcvec);
51 allones = test_for_ones(srcvec);
52 if (allzeros != expected_allzeros_results[iter]) {
53 printf("fail on allzero check. iter %d, result was %d \n", iter, allzeros);
54 failcount++;
55 }
56 if (allones != expected_allones_results[iter]) {
57 printf("fail on allones check. iter %d, result was %d \n", iter, allones);
58 failcount++;
59 }
60 }
61
62 if (failcount)
63 abort();
64 return 0;
65 }
66