From d3884ca6dc730e477694a072735df825965df92b Mon Sep 17 00:00:00 2001 From: RealTimeChris <40668522+RealTimeChris@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:00:26 -0400 Subject: [PATCH] fix: Update DetectArchitecture.cmake to only search for required CPU-flags. (#816) --- cmake/DetectArchitecture.cmake | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cmake/DetectArchitecture.cmake b/cmake/DetectArchitecture.cmake index 4deed03e25..b5d41f5e1c 100644 --- a/cmake/DetectArchitecture.cmake +++ b/cmake/DetectArchitecture.cmake @@ -25,16 +25,16 @@ endfunction() if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(INSTRUCTION_SETS - "T_AVX?/arch:AVX?auto result = _mm_testz_ps(__m128{}, __m128{})" - "T_AVX2?/arch:AVX2?auto result = _mm256_add_epi32(__m256i{}, __m256i{})" - "T_AVX512?/arch:AVX512?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{})" + "T_AVX?/arch:AVX?__m128i value{}#auto result = _mm_extract_epi32(value, 0)" + "T_AVX2?/arch:AVX2?__m256i value{}#auto result = _mm256_extract_epi32(value, 0)" + "T_AVX512?/arch:AVX512?int32_t result[16]#const _mm512i& value{}#_mm512_store_si512(result, value)" ) else() set(INSTRUCTION_SETS - "T_AVX?-mavx.-mpclmul.-mbmi?auto result = _mm_testz_ps(__m128{}, __m128{})" - "T_AVX2?-mavx2.-mavx.-mpclmul.-mbmi?auto result = _mm256_add_epi32(__m256i{}, __m256i{})" - "T_AVX512?-mavx512bw.-mavx512f.-mavx2.-mavx.-mpclmul.-mbmi?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{})" - ) + "T_AVX?-mavx?__m128i value{}#auto result = _mm_extract_epi32(value, 0)" + "T_AVX2?-mavx2?__m256i value{}#auto result = _mm256_extract_epi32(value, 0)" + "T_AVX512?-mavx512f?int32_t result[16]#const _mm512i& value{}#_mm512_store_si512(result, value)" +) endif() set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}") @@ -42,15 +42,15 @@ set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}") set(AVX_NAME "T_Fallback") if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386")) - foreach(INSTRUCTION_SET IN LISTS INSTRUCTION_SETS) - string(REPLACE "?" ";" CURRENT_LIST "${INSTRUCTION_SET}") - list(GET CURRENT_LIST 0 INSTRUCTION_SET_NAME) - list(GET CURRENT_LIST 1 INSTRUCTION_SET_FLAG) - string(REPLACE "." ";" INSTRUCTION_SET_FLAG "${INSTRUCTION_SET_FLAG}") - list(GET CURRENT_LIST 2 INSTRUCTION_SET_INTRINSIC) - string(REPLACE "." ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}") - check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_FLAG}" "${INSTRUCTION_SET_INTRINSIC}") - endforeach() +foreach(INSTRUCTION_SET IN LISTS INSTRUCTION_SETS) + string(REPLACE "?" ";" CURRENT_LIST "${INSTRUCTION_SET}") + list(GET CURRENT_LIST 0 INSTRUCTION_SET_NAME) + list(GET CURRENT_LIST 1 INSTRUCTION_SET_FLAG) + string(REPLACE "." ";" INSTRUCTION_SET_FLAG "${INSTRUCTION_SET_FLAG}") + list(GET CURRENT_LIST 2 INSTRUCTION_SET_INTRINSIC) + string(REPLACE "#" ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}") + check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_FLAG}" "${INSTRUCTION_SET_INTRINSIC}") +endforeach() string(REPLACE "T_" "" AVX_DISPLAY ${AVX_NAME}) message(STATUS "Detected ${CMAKE_SYSTEM_PROCESSOR} SSE type: ${AVX_DISPLAY}")