From 16eaa2174f91eaa934b76fecbdbb5a648de96b3c Mon Sep 17 00:00:00 2001 From: Mathias Berchtold Date: Sat, 21 Feb 2026 19:22:16 -0700 Subject: [PATCH 1/2] Vector algorithms: Add compile time checks for ISA features When the STL is compiled with /arch:SSE4.2 or /arch:AVX2, the runtime checks for the respective ISA features (SSE42, AVX2) are unnecessary. This change adds a compile time check using __check_arch_support to avoid the runtime cost. --- stl/src/vector_algorithms.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index e4b29de2a5..a723d7d387 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -29,11 +29,11 @@ extern "C" long __isa_enabled; namespace { #if !defined(_M_ARM64) && !defined(_M_ARM64EC) bool _Use_avx2() noexcept { - return __isa_enabled & (1 << __ISA_AVAILABLE_AVX2); + return __check_arch_support(__IA_SUPPORT_VECTOR256, 0) || __isa_enabled & (1 << __ISA_AVAILABLE_AVX2); } bool _Use_sse42() noexcept { - return __isa_enabled & (1 << __ISA_AVAILABLE_SSE42); + return __check_arch_support(__IA_SUPPORT_SSE42, 0) || (__isa_enabled & (1 << __ISA_AVAILABLE_SSE42)); } struct [[nodiscard]] _Zeroupper_on_exit { // TRANSITION, DevCom-10331414 @@ -9956,3 +9956,4 @@ __declspec(noalias) bool __stdcall __std_bitset_from_string_2(void* const _Dest, } // extern "C" #endif // ^^^ !defined(_M_ARM64) ^^^ + From 7b3e8321dceba13db3f5be7d1fd5070c774ae482 Mon Sep 17 00:00:00 2001 From: Mathias Berchtold Date: Sat, 21 Feb 2026 21:00:50 -0700 Subject: [PATCH 2/2] remove extra CRLF --- stl/src/vector_algorithms.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index a723d7d387..af1e334192 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -9956,4 +9956,3 @@ __declspec(noalias) bool __stdcall __std_bitset_from_string_2(void* const _Dest, } // extern "C" #endif // ^^^ !defined(_M_ARM64) ^^^ -