cpu_popcnt.c 370 B

1234567891011121314151617181920212223
  1. #ifdef _MSC_VER
  2. #include <nmmintrin.h>
  3. #else
  4. #include <popcntintrin.h>
  5. #endif
  6. int main(void)
  7. {
  8. long long a = 0;
  9. int b;
  10. #ifdef _MSC_VER
  11. #ifdef _M_X64
  12. a = _mm_popcnt_u64(1);
  13. #endif
  14. b = _mm_popcnt_u32(1);
  15. #else
  16. #ifdef __x86_64__
  17. a = __builtin_popcountll(1);
  18. #endif
  19. b = __builtin_popcount(1);
  20. #endif
  21. return (int)a + b;
  22. }