Debian Codegraph @

gcc/testsuite/gcc.target/i386/pr109011-b2.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O3 -mbmi -mlzcnt -mavx512vl -mavx512cd -mavx512bitalg -mavx512vpopcntdq -mprefer-vector-width=256" } */
3 /* { dg-require-effective-target avx512f } */
4 /* { dg-require-effective-target avx512vl } */
5 /* { dg-require-effective-target avx512cd } */
6 /* { dg-require-effective-target avx512bitalg } */
7 /* { dg-require-effective-target avx512vpopcntdq } */
8
9 #define AVX512F
10 #define AVX512VL
11 #define AVX512CD
12 #define AVX512BITALG
13 #define AVX512VPOPCNTDQ
14
15 #include "avx512f-helper.h"
16 #include "pr109011-b1.c"
17
18 void
19 __attribute__((noipa, optimize ("no-tree-vectorize")))
20 popcntb_scalar (unsigned char *p, unsigned char *q)
21 {
22 for (unsigned int i = 0; i < 2048; ++i)
23 p[i] = __builtin_popcount (q[i]);
24 }
25
26 void
27 __attribute__((noipa, optimize ("no-tree-vectorize")))
28 clzb_scalar (unsigned char *p, unsigned char* __restrict q)
29 {
30 for (unsigned int i = 0; i < 2048; ++i)
31 p[i] = __builtin_clz (q[i]);
32 }
33
34 void
35 __attribute__((noipa, optimize ("no-tree-vectorize")))
36 ffsb_scalar (unsigned char *p, unsigned char* __restrict q)
37 {
38 for (unsigned int i = 0; i < 2048; ++i)
39 p[i] = __builtin_ffs (q[i]);
40 }
41
42 void
43 __attribute__((noipa, optimize ("no-tree-vectorize")))
44 clzb0_scalar (unsigned char *p, unsigned char* __restrict q)
45 {
46 for (unsigned int i = 0; i < 2048; ++i)
47 p[i] = q[i] ? __builtin_clz (q[i]) : 8;
48 }
49
50 void
51 __attribute__((noipa, optimize ("no-tree-vectorize")))
52 ctzb0_scalar (unsigned char *p, unsigned char* __restrict q)
53 {
54 for (unsigned int i = 0; i < 2048; ++i)
55 p[i] = q[i] ? __builtin_ctz (q[i]) : 8;
56 }
57
58 void
59 test_256 ()
60 {
61 unsigned char src[2048];
62 unsigned char res[2048];
63 unsigned char exp[2048];
64 for (int i = 0; i != 2048; i++)
65 {
66 src[i] = i * i - 1;
67 res[i] = 0;
68 exp[i] = 1;
69 }
70
71 popcntb (&res[0], &src[0]);
72 popcntb_scalar (&exp[0], &src[0]);
73
74 if (__builtin_memcmp (res, exp, 2048) != 0)
75 __builtin_abort ();
76
77 clzb (&res[0], &src[0]);
78 clzb_scalar (&exp[0], &src[0]);
79
80 if (__builtin_memcmp (res, exp, 2048) != 0)
81 __builtin_abort ();
82
83 ffsb (&res[0], &src[0]);
84 ffsb_scalar (&exp[0], &src[0]);
85
86 if (__builtin_memcmp (res, exp, 2048) != 0)
87 __builtin_abort ();
88
89 clzb0 (&res[0], &src[0]);
90 clzb0_scalar (&exp[0], &src[0]);
91
92 if (__builtin_memcmp (res, exp, 2048) != 0)
93 __builtin_abort ();
94
95 ctzb0 (&res[0], &src[0]);
96 ctzb0_scalar (&exp[0], &src[0]);
97
98 if (__builtin_memcmp (res, exp, 2048) != 0)
99 __builtin_abort ();
100 }
101
102 void
103 test_128 ()
104 {}