Skip to content

Commit 7ff7c47

Browse files
committed
Add -march=native for gcc-compat on Intel
not valid on arm or other archs. Only for gcc-compatible compilers. 30% faster on small samples than -flto
1 parent cda803a commit 7ff7c47

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,21 @@ if(ipo_supported)
238238
message(STATUS "IPO / LTO enabled")
239239
set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
240240
add_definitions(-DLTO)
241+
if ((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
242+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
243+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "i586")
244+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "i686")
245+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") # freebsd
246+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") # windows
247+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86"))
248+
set(PROCESSOR_FAMILY "Intel")
249+
if(CMAKE_COMPILER_IS_GNUCC
250+
OR (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang)
251+
OR (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
252+
OR (CMAKE_CXX_COMPILER_ID STREQUAL Intel))
253+
add_definitions(-march=native)
254+
endif()
255+
endif()
241256
else()
242257
message(STATUS "IPO / LTO not supported: <${error}>")
243258
endif()

0 commit comments

Comments
 (0)