Skip to content

Commit

Permalink
Merge pull request #98 from eseiler/fix/bmi
Browse files Browse the repository at this point in the history
[FIX] missing BMI check
  • Loading branch information
eseiler authored Dec 16, 2021
2 parents c57ebcc + 77aae34 commit 9930944
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CMakeModules/BMI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <stdint.h>
#include <x86intrin.h>

int main()
{
uint64_t res = _tzcnt_u64(1ULL);
}
19 changes: 17 additions & 2 deletions CMakeModules/DetectCPUFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ file(READ "${CMAKE_MODULE_PATH}/SSE42.cpp" test_source_sse42)
CHECK_CXX_SOURCE_RUNS("${test_source_sse42}" HAVE_SSE42)
set(CMAKE_REQUIRED_FLAGS "")

set(CMAKE_REQUIRED_FLAGS "-mbmi")
file(READ "${CMAKE_MODULE_PATH}/BMI.cpp" test_source_bmi)
CHECK_CXX_SOURCE_RUNS("${test_source_bmi}" HAVE_BMI)
set(CMAKE_REQUIRED_FLAGS "")

set(CMAKE_REQUIRED_FLAGS "-mbmi2")
file(READ "${CMAKE_MODULE_PATH}/BMI2.cpp" test_source_bmi2)
CHECK_CXX_SOURCE_RUNS("${test_source_bmi2}" HAVE_BMI2)
Expand All @@ -27,7 +32,17 @@ if(HAVE_SSE42)
endif()
else()
set(HAVE_SSE42 0)
message(STATUS "${Red}Compiler does NOT supports SSE4.2${ColourReset}")
message(STATUS "${Red}Compiler does NOT support SSE4.2${ColourReset}")
endif()

if(HAVE_BMI)
message(STATUS "${Green}Compiler supports BMI${ColourReset}")
if(NOT MSVC)
CheckAndAppendCompilerFlags(${CMAKE_BUILD_TYPE} "-mbmi")
endif()
else()
set(HAVE_BMI 0)
message(STATUS "${Red}Compiler does NOT support BMI${ColourReset}")
endif()

if(HAVE_BMI2)
Expand All @@ -37,7 +52,7 @@ if(HAVE_BMI2)
endif()
else()
set(HAVE_BMI2 0)
message(STATUS "${Red}Compiler does NOT supports BMI2${ColourReset}")
message(STATUS "${Red}Compiler does NOT support BMI2${ColourReset}")
endif()

file(READ "${CMAKE_MODULE_PATH}/MODETI.cpp" test_source_modeti)
Expand Down

0 comments on commit 9930944

Please sign in to comment.