From e4ab7cea3f565ecf8538f7eb1bb1d42abfc267c7 Mon Sep 17 00:00:00 2001 From: jovibor Date: Mon, 30 Mar 2026 10:49:19 +0100 Subject: [PATCH 1/2] Add static and [[nodiscard]] to _Use_avx2() and _Use_sse42() --- stl/src/vector_algorithms.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index a3d5dc8afb..14215af23a 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -24,12 +24,16 @@ extern "C" long __isa_enabled; namespace { #if !defined(_M_ARM64) && !defined(_M_ARM64EC) - bool _Use_avx2() noexcept { - return __check_arch_support(__IA_SUPPORT_VECTOR256, 0) || (__isa_enabled & (1 << __ISA_AVAILABLE_AVX2)); + [[nodiscard]] bool _Use_avx2() noexcept { + const static bool _HasAVX2 = + __check_arch_support(__IA_SUPPORT_VECTOR256, 0) || (__isa_enabled & (1 << __ISA_AVAILABLE_AVX2)); + return _HasAVX2; } - bool _Use_sse42() noexcept { - return __check_arch_support(__IA_SUPPORT_SSE42, 0) || (__isa_enabled & (1 << __ISA_AVAILABLE_SSE42)); + [[nodiscard]] bool _Use_sse42() noexcept { + const static bool _HasSSE42 = + __check_arch_support(__IA_SUPPORT_SSE42, 0) || (__isa_enabled & (1 << __ISA_AVAILABLE_SSE42)); + return _HasSSE42; } struct [[nodiscard]] _Zeroupper_on_exit { // TRANSITION, DevCom-10331414 From d3aea1f31caf2588869e6808aea30311da97ca96 Mon Sep 17 00:00:00 2001 From: jovibor Date: Mon, 30 Mar 2026 23:51:27 +0100 Subject: [PATCH 2/2] Leaving only [[nodiscard]] --- stl/src/vector_algorithms.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index 14215af23a..4ad1d45a41 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -25,15 +25,11 @@ extern "C" long __isa_enabled; namespace { #if !defined(_M_ARM64) && !defined(_M_ARM64EC) [[nodiscard]] bool _Use_avx2() noexcept { - const static bool _HasAVX2 = - __check_arch_support(__IA_SUPPORT_VECTOR256, 0) || (__isa_enabled & (1 << __ISA_AVAILABLE_AVX2)); - return _HasAVX2; + return __check_arch_support(__IA_SUPPORT_VECTOR256, 0) || (__isa_enabled & (1 << __ISA_AVAILABLE_AVX2)); } [[nodiscard]] bool _Use_sse42() noexcept { - const static bool _HasSSE42 = - __check_arch_support(__IA_SUPPORT_SSE42, 0) || (__isa_enabled & (1 << __ISA_AVAILABLE_SSE42)); - return _HasSSE42; + return __check_arch_support(__IA_SUPPORT_SSE42, 0) || (__isa_enabled & (1 << __ISA_AVAILABLE_SSE42)); } struct [[nodiscard]] _Zeroupper_on_exit { // TRANSITION, DevCom-10331414