Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CPU][ARM] Lower SVE-clone auto-vectorizer to NEON to prevent SIGILL on non-SVE cores (#36931)

Nesterov Alexander743bbe2e920a
diff --git a/cmake/developer_package/compile_flags/functions.cmake b/cmake/developer_package/compile_flags/functions.cmake
index fccce4df8c0..a04e8ea3a24 100644
--- a/cmake/developer_package/compile_flags/functions.cmake
+++ b/cmake/developer_package/compile_flags/functions.cmake
@@ -279,6 +279,21 @@ macro(ov_arm_sve_optimization_flags flags)
endif()
if(NOT CMAKE_CL_64)
list(APPEND ${flags} -ftree-vectorize)
+ # Keep auto-vectorization but restrict it to Advanced SIMD (NEON) for these SVE clones.
+ # Under -march=+sve the auto-vectorizer otherwise turns generic STL templates (e.g.
+ # std::vector<T>::_M_default_append zero-init/resize) into SVE. Such instantiations are
+ # emitted as WEAK COMDAT symbols with default visibility, so the linker may select the SVE
+ # copy as the single definition used by baseline (non-SVE) translation units too, executing
+ # illegal SVE on cores without SVE (e.g. Cortex-A72) and crashing with SIGILL. Lowering the
+ # auto-vectorizer to NEON (legal on every ARMv8-A core) keeps the generic loops vectorized
+ # while preserving the intentional SVE kernels, which use explicit ACLE intrinsics
+ # (svld1/svmla_f32/...) and are unaffected. Both GCC and Clang auto-vectorize to SVE here,
+ # but the knob is compiler-specific (Android/MSVC/IntelLLVM handled above).
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ list(APPEND ${flags} --param=aarch64-autovec-preference=1)
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|AppleClang)$")
+ list(APPEND ${flags} -mllvm -scalable-vectorization=off)
+ endif()
endif()
set(${flags} ${${flags}})