cpu_popcnt.cpp 511 B

123456789101112131415161718192021222324
  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. #elif defined(__POPCNT__)
  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
  13. #else
  14. # error "__POPCNT__ is not defined by compiler"
  15. #endif
  16. int main()
  17. {
  18. #ifdef CV_POPCNT_U64
  19. int i = CV_POPCNT_U64(1);
  20. #endif
  21. int j = CV_POPCNT_U32(1);
  22. return 0;
  23. }