File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818
1919#if (defined(__AVX2__) || defined(__SSE2__)) && !defined(CSV_NO_SIMD)
2020#include < immintrin.h>
21+ // _tzcnt_u32 in GCC/Clang headers is __attribute__(__target__("bmi")), which
22+ // requires -mbmi at the call site. __builtin_ctz has no such restriction and
23+ // emits BSF/TZCNT as the optimizer sees fit. MSVC's _tzcnt_u32 has no
24+ // equivalent restriction, so keep it there.
25+ # ifdef _MSC_VER
26+ # define CSV_TZCNT32 (x ) _tzcnt_u32(x)
27+ # else
28+ # define CSV_TZCNT32 (x ) static_cast <unsigned >(__builtin_ctz(x))
29+ # endif
2130#endif
2231
2332namespace csv {
@@ -84,7 +93,7 @@ namespace csv {
8493 int mask = _mm256_movemask_epi8 (special);
8594
8695 if (mask != 0 )
87- return pos + _tzcnt_u32 ( mask);
96+ return pos + CSV_TZCNT32 ( static_cast < unsigned >( mask) );
8897 pos += 32 ;
8998 }
9099#elif defined(__SSE2__) && !defined(CSV_NO_SIMD)
@@ -97,7 +106,7 @@ namespace csv {
97106 int mask = _mm_movemask_epi8 (special);
98107
99108 if (mask != 0 )
100- return pos + _tzcnt_u32 ( mask);
109+ return pos + CSV_TZCNT32 ( static_cast < unsigned >( mask) );
101110 pos += 16 ;
102111 }
103112#else
You can’t perform that action at this time.
0 commit comments