Skip to content

Commit e04d663

Browse files
committed
Merge pull request opencv#8656 from alalek:fix_cpu_detection
2 parents c5c3ec4 + 4c2858f commit e04d663

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

cmake/checks/cpu_popcnt.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
#include <nmmintrin.h>
2-
#ifndef _MSC_VER
3-
#include <popcntintrin.h>
1+
#ifdef _MSC_VER
2+
# include <nmmintrin.h>
3+
# if defined(_M_X64)
4+
# define CV_POPCNT_U64 _mm_popcnt_u64
5+
# endif
6+
# define CV_POPCNT_U32 _mm_popcnt_u32
7+
#else
8+
# include <popcntintrin.h>
9+
# if defined(__x86_64__)
10+
# define CV_POPCNT_U64 __builtin_popcountll
11+
# endif
12+
# define CV_POPCNT_U32 __builtin_popcount
413
#endif
5-
int main() {
6-
int i = _mm_popcnt_u64(1);
14+
15+
int main()
16+
{
17+
#ifdef CV_POPCNT_U64
18+
int i = CV_POPCNT_U64(1);
19+
#endif
20+
int j = CV_POPCNT_U32(1);
721
return 0;
822
}

cmake/checks/cpu_sse42.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <nmmintrin.h>
2-
int main() {
3-
int i = _mm_popcnt_u64(1);
2+
3+
int main()
4+
{
5+
unsigned int res = _mm_crc32_u8(1, 2);
46
return 0;
57
}

0 commit comments

Comments
 (0)