@@ -86,8 +86,8 @@ inline bool cpu_has_popcnt() {
8686
8787inline bool cpu_has_popcnt () { return false ; }
8888
89- #define POPCNT_INTRINSIC (x ) sw_count_1s (x)
90- #define BITSCAN_INTRINSIC (idx, x ) sw_count_1s (x) // dummy
89+ #define POPCNT_INTRINSIC (x ) count_1s (x)
90+ #define BITSCAN_INTRINSIC (idx, x ) count_1s (x) // dummy
9191
9292#endif
9393
@@ -96,19 +96,19 @@ inline bool cpu_has_popcnt() { return false; }
9696
9797#if defined(BITCOUNT_LOOP)
9898
99- inline int sw_count_1s (Bitboard b) {
99+ inline int count_1s (Bitboard b) {
100100 int r;
101101 for (r = 0 ; b; r++, b &= b - 1 );
102102 return r;
103103}
104104
105- inline int sw_count_1s_max_15 (Bitboard b) {
105+ inline int count_1s_max_15 (Bitboard b) {
106106 return count_1s (b);
107107}
108108
109109#elif defined(BITCOUNT_SWAR_32)
110110
111- inline int sw_count_1s (Bitboard b) {
111+ inline int count_1s (Bitboard b) {
112112 unsigned w = unsigned (b >> 32 ), v = unsigned (b);
113113 v -= (v >> 1 ) & 0x55555555 ; // 0-2 in 2 bits
114114 w -= (w >> 1 ) & 0x55555555 ;
@@ -120,7 +120,7 @@ inline int sw_count_1s(Bitboard b) {
120120 return int (v >> 24 );
121121}
122122
123- inline int sw_count_1s_max_15 (Bitboard b) {
123+ inline int count_1s_max_15 (Bitboard b) {
124124 unsigned w = unsigned (b >> 32 ), v = unsigned (b);
125125 v -= (v >> 1 ) & 0x55555555 ; // 0-2 in 2 bits
126126 w -= (w >> 1 ) & 0x55555555 ;
@@ -133,15 +133,15 @@ inline int sw_count_1s_max_15(Bitboard b) {
133133
134134#elif defined(BITCOUNT_SWAR_64)
135135
136- inline int sw_count_1s (Bitboard b) {
136+ inline int count_1s (Bitboard b) {
137137 b -= ((b>>1 ) & 0x5555555555555555ULL );
138138 b = ((b>>2 ) & 0x3333333333333333ULL ) + (b & 0x3333333333333333ULL );
139139 b = ((b>>4 ) + b) & 0x0F0F0F0F0F0F0F0FULL ;
140140 b *= 0x0101010101010101ULL ;
141141 return int (b >> 56 );
142142}
143143
144- inline int sw_count_1s_max_15 (Bitboard b) {
144+ inline int count_1s_max_15 (Bitboard b) {
145145 b -= (b>>1 ) & 0x5555555555555555ULL ;
146146 b = ((b>>2 ) & 0x3333333333333333ULL ) + (b & 0x3333333333333333ULL );
147147 b *= 0x1111111111111111ULL ;
@@ -158,35 +158,16 @@ inline int sw_count_1s_max_15(Bitboard b) {
158158template <bool UseIntrinsic>
159159inline int count_1s (Bitboard b) {
160160
161- return UseIntrinsic ? POPCNT_INTRINSIC (b) : sw_count_1s (b);
161+ return UseIntrinsic ? POPCNT_INTRINSIC (b) : count_1s (b);
162162}
163163
164164template <bool UseIntrinsic>
165165inline int count_1s_max_15 (Bitboard b) {
166166
167- return UseIntrinsic ? POPCNT_INTRINSIC (b) : sw_count_1s_max_15 (b);
167+ return UseIntrinsic ? POPCNT_INTRINSIC (b) : count_1s_max_15 (b);
168168}
169169
170170
171- // Global variable initialized at startup that is set to true if
172- // CPU on which application runs supports POPCNT intrinsic. Unless
173- // DISABLE_POPCNT_SUPPORT is defined.
174- #if defined(DISABLE_POPCNT_SUPPORT)
175- const bool CpuHasPOPCNT = false ;
176- #else
177- const bool CpuHasPOPCNT = cpu_has_popcnt();
178- #endif
179-
180-
181- // Global variable used to print info about the use of 64 optimized
182- // functions to verify that a 64bit compile has been correctly built.
183- #if defined(BITCOUNT_SWAR_64)
184- const bool CpuHas64BitPath = true ;
185- #else
186- const bool CpuHas64BitPath = false ;
187- #endif
188-
189-
190171// / pop_1st_bit() finds and clears the least significant nonzero bit in a
191172// / nonzero bitboard. If template parameter is true an intrinsic is called,
192173// / otherwise we fallback on a software implementation.
@@ -207,4 +188,23 @@ inline Square pop_1st_bit<true>(Bitboard *b) {
207188 return Square (idx);
208189}
209190
191+
192+ // Global variable initialized at startup that is set to true if
193+ // CPU on which application runs supports POPCNT intrinsic. Unless
194+ // DISABLE_POPCNT_SUPPORT is defined.
195+ #if defined(DISABLE_POPCNT_SUPPORT)
196+ const bool CpuHasPOPCNT = false ;
197+ #else
198+ const bool CpuHasPOPCNT = cpu_has_popcnt();
199+ #endif
200+
201+
202+ // Global variable used to print info about the use of 64 optimized
203+ // functions to verify that a 64bit compile has been correctly built.
204+ #if defined(BITCOUNT_SWAR_64)
205+ const bool CpuHas64BitPath = true ;
206+ #else
207+ const bool CpuHas64BitPath = false ;
208+ #endif
209+
210210#endif // !defined(BITCOUNT_H_INCLUDED)
0 commit comments