2017-01-27 19:55:33 +00:00
|
|
|
# https://software.intel.com/sites/landingpage/IntrinsicsGuide/
|
|
|
|
|
|
|
|
include (CheckCXXSourceCompiles)
|
2017-07-17 14:21:43 +00:00
|
|
|
include (CMakePushCheckState)
|
|
|
|
|
|
|
|
cmake_push_check_state ()
|
2017-01-27 19:55:33 +00:00
|
|
|
|
|
|
|
# gcc -dM -E -mno-sse2 - < /dev/null | sort > gcc-dump-nosse2
|
|
|
|
# gcc -dM -E -msse2 - < /dev/null | sort > gcc-dump-sse2
|
|
|
|
#define __SSE2__ 1
|
|
|
|
#define __SSE2_MATH__ 1
|
|
|
|
|
|
|
|
# gcc -dM -E -msse4.1 - < /dev/null | sort > gcc-dump-sse41
|
|
|
|
#define __SSE4_1__ 1
|
|
|
|
|
|
|
|
set (TEST_FLAG "-msse4.1")
|
2018-09-28 14:53:20 +00:00
|
|
|
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG} -O0")
|
2017-01-27 19:55:33 +00:00
|
|
|
check_cxx_source_compiles("
|
2017-04-01 07:20:54 +00:00
|
|
|
#include <smmintrin.h>
|
|
|
|
int main() {
|
2018-09-28 14:53:20 +00:00
|
|
|
auto a = _mm_insert_epi8(__m128i(), 0, 0);
|
|
|
|
(void)a;
|
2017-04-01 07:20:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-01-27 19:55:33 +00:00
|
|
|
" HAVE_SSE41)
|
|
|
|
if (HAVE_SSE41)
|
2017-04-01 07:20:54 +00:00
|
|
|
set (COMPILER_FLAGS "${COMPILER_FLAGS} ${TEST_FLAG}")
|
2017-01-27 19:55:33 +00:00
|
|
|
endif ()
|
|
|
|
|
2019-01-23 15:24:14 +00:00
|
|
|
if (ARCH_PPC64LE)
|
2019-01-23 14:18:19 +00:00
|
|
|
set (COMPILER_FLAGS "${COMPILER_FLAGS} -maltivec -D__SSE2__=1 -DNO_WARN_X86_INTRINSICS")
|
|
|
|
endif ()
|
2017-01-27 19:55:33 +00:00
|
|
|
|
|
|
|
# gcc -dM -E -msse4.2 - < /dev/null | sort > gcc-dump-sse42
|
|
|
|
#define __SSE4_2__ 1
|
|
|
|
|
|
|
|
set (TEST_FLAG "-msse4.2")
|
2018-09-28 14:53:20 +00:00
|
|
|
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG} -O0")
|
2017-01-27 19:55:33 +00:00
|
|
|
check_cxx_source_compiles("
|
2017-04-01 07:20:54 +00:00
|
|
|
#include <nmmintrin.h>
|
|
|
|
int main() {
|
2018-09-28 14:53:20 +00:00
|
|
|
auto a = _mm_crc32_u64(0, 0);
|
|
|
|
(void)a;
|
2017-04-01 07:20:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-01-27 19:55:33 +00:00
|
|
|
" HAVE_SSE42)
|
|
|
|
if (HAVE_SSE42)
|
2017-04-01 07:20:54 +00:00
|
|
|
set (COMPILER_FLAGS "${COMPILER_FLAGS} ${TEST_FLAG}")
|
2017-01-27 19:55:33 +00:00
|
|
|
endif ()
|
|
|
|
|
2018-11-02 19:06:05 +00:00
|
|
|
set (TEST_FLAG "-mssse3")
|
|
|
|
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG} -O0")
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <tmmintrin.h>
|
|
|
|
int main() {
|
|
|
|
__m64 a = _mm_abs_pi8(__m64());
|
|
|
|
(void)a;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_SSSE3)
|
|
|
|
|
|
|
|
set (TEST_FLAG "-mavx")
|
|
|
|
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG} -O0")
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <immintrin.h>
|
|
|
|
int main() {
|
|
|
|
auto a = _mm256_insert_epi8(__m256i(), 0, 0);
|
|
|
|
(void)a;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_AVX)
|
|
|
|
|
|
|
|
set (TEST_FLAG "-mavx2")
|
|
|
|
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG} -O0")
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <immintrin.h>
|
|
|
|
int main() {
|
|
|
|
auto a = _mm256_add_epi16(__m256i(), __m256i());
|
|
|
|
(void)a;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_AVX2)
|
2017-01-27 19:55:33 +00:00
|
|
|
|
2019-08-07 14:08:15 +00:00
|
|
|
set (TEST_FLAG "-mpclmul")
|
|
|
|
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG} -O0")
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <wmmintrin.h>
|
|
|
|
int main() {
|
|
|
|
auto a = _mm_clmulepi64_si128(__m128i(), __m128i(), 0);
|
|
|
|
(void)a;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_PCLMULQDQ)
|
|
|
|
|
2017-01-27 19:55:33 +00:00
|
|
|
# gcc -dM -E -mpopcnt - < /dev/null | sort > gcc-dump-popcnt
|
|
|
|
#define __POPCNT__ 1
|
|
|
|
|
|
|
|
set (TEST_FLAG "-mpopcnt")
|
|
|
|
|
2018-09-28 14:53:20 +00:00
|
|
|
set (CMAKE_REQUIRED_FLAGS "${TEST_FLAG} -O0")
|
2017-01-27 19:55:33 +00:00
|
|
|
check_cxx_source_compiles("
|
2017-04-01 07:20:54 +00:00
|
|
|
int main() {
|
2018-09-28 14:53:20 +00:00
|
|
|
auto a = __builtin_popcountll(0);
|
|
|
|
(void)a;
|
2017-04-01 07:20:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-01-27 19:55:33 +00:00
|
|
|
" HAVE_POPCNT)
|
|
|
|
|
2017-08-09 20:52:55 +00:00
|
|
|
if (HAVE_POPCNT AND NOT ARCH_AARCH64)
|
2017-04-01 07:20:54 +00:00
|
|
|
set (COMPILER_FLAGS "${COMPILER_FLAGS} ${TEST_FLAG}")
|
2017-01-27 19:55:33 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-07-17 14:21:43 +00:00
|
|
|
cmake_pop_check_state ()
|