From e5987569d3dbe680f9b772d957db43e2fa18390c Mon Sep 17 00:00:00 2001 From: Aliaksei Urbanski Date: Mon, 31 Mar 2025 13:23:38 +0200 Subject: [PATCH] Fix #134933: False positive SUPPORT_SSE42_BUILD When you build Blender with optimization flags, such as `-O1` or higher, [this check](https://projects.blender.org/blender/blender/src/branch/main/build_files/cmake/macros.cmake#L572-L576) always passes, so `SUPPORT_SSE42_BUILD` is set to false positive value even when a CPU doesn't actually support `SSE4.2`. This fix prevents a compiler from throwing away `SSE4.2` instructions. _Best regards!_ Pull Request: https://projects.blender.org/blender/blender/pulls/135685 --- build_files/cmake/macros.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index bb5e66d75d1..7fcbfb1c7f0 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -572,7 +572,13 @@ macro(TEST_SSE_SUPPORT check_c_source_runs(" #include #include - int main(void) { __m128i v = _mm_setzero_si128(); v = _mm_cmpgt_epi64(v,v); return 0; }" + #include + int main(void) { + __m128i v = _mm_setzero_si128(); + v = _mm_cmpgt_epi64(v,v); + if (_mm_test_all_zeros(v, v)) return 0; + return 1; + }" SUPPORT_SSE42_BUILD) endif()