diff --git a/cmake/DetectArchitecture.cmake b/cmake/DetectArchitecture.cmake index ed8698e264..45a4f13ac2 100644 --- a/cmake/DetectArchitecture.cmake +++ b/cmake/DetectArchitecture.cmake @@ -40,21 +40,25 @@ endif() set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}") set(AVX_NAME "T_fallback") + +# This is only supported on x86/x64, it is completely skipped and forced to T_fallback anywhere else if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")) -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}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE}") else() message(STATUS "SSE not supported by architecture ${CMAKE_SYSTEM_PROCESSOR} ${AVX_NAME}") + set(AVX_NAME "T_fallback") + set(AVX_TYPE "T_fallback") endif() diff --git a/include/dpp/discordvoiceclient.h b/include/dpp/discordvoiceclient.h index 39c5036356..1144dda7f9 100644 --- a/include/dpp/discordvoiceclient.h +++ b/include/dpp/discordvoiceclient.h @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/include/dpp/isa_detection.h b/include/dpp/isa_detection.h index 0f4831ad94..233baedb7f 100644 --- a/include/dpp/isa_detection.h +++ b/include/dpp/isa_detection.h @@ -22,6 +22,11 @@ #if defined _MSC_VER || defined __GNUC__ || defined __clang__ + /* Sanity check for cases of broken detection */ + #if !defined(__i386__) && !defined(__x86_64__) && !defined(T_fallback) + #define T_fallback 1 + #endif + #ifndef T_fallback #include @@ -40,21 +45,21 @@ */ inline int32_t extract_int32_from_avx(const avx_int& value, int64_t index) { switch (index) { - case 0: { - return _mm_extract_epi32(value, 0); - } - case 1: { - return _mm_extract_epi32(value, 1); - } - case 2: { - return _mm_extract_epi32(value, 2); - } - case 3: { - return _mm_extract_epi32(value, 3); - } - default: { - return _mm_extract_epi32(value, 0); - } + case 0: { + return _mm_extract_epi32(value, 0); + } + case 1: { + return _mm_extract_epi32(value, 1); + } + case 2: { + return _mm_extract_epi32(value, 2); + } + case 3: { + return _mm_extract_epi32(value, 3); + } + default: { + return _mm_extract_epi32(value, 0); + } } } @@ -66,33 +71,33 @@ */ inline int32_t extract_int32_from_avx2(const avx_2_int& value, int64_t index) { switch (index) { - case 0: { - return _mm256_extract_epi32(value, 0); - } - case 1: { - return _mm256_extract_epi32(value, 1); - } - case 2: { - return _mm256_extract_epi32(value, 2); - } - case 3: { - return _mm256_extract_epi32(value, 3); - } - case 4: { - return _mm256_extract_epi32(value, 4); - } - case 5: { - return _mm256_extract_epi32(value, 5); - } - case 6: { - return _mm256_extract_epi32(value, 6); - } - case 7: { - return _mm256_extract_epi32(value, 7); - } - default: { - return _mm256_extract_epi32(value, 0); - } + case 0: { + return _mm256_extract_epi32(value, 0); + } + case 1: { + return _mm256_extract_epi32(value, 1); + } + case 2: { + return _mm256_extract_epi32(value, 2); + } + case 3: { + return _mm256_extract_epi32(value, 3); + } + case 4: { + return _mm256_extract_epi32(value, 4); + } + case 5: { + return _mm256_extract_epi32(value, 5); + } + case 6: { + return _mm256_extract_epi32(value, 6); + } + case 7: { + return _mm256_extract_epi32(value, 7); + } + default: { + return _mm256_extract_epi32(value, 0); + } } } diff --git a/src/dpp/discordvoiceclient.cpp b/src/dpp/discordvoiceclient.cpp index 4486ad7f72..2d0d766349 100644 --- a/src/dpp/discordvoiceclient.cpp +++ b/src/dpp/discordvoiceclient.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include