Skip to content

Commit cfb585b

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 330b9cf commit cfb585b

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
@@ -206,6 +206,21 @@ if(ipo_supported)
206206
message(STATUS "IPO / LTO enabled")
207207
set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
208208
add_definitions(-DLTO)
209+
if ((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
210+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
211+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "i586")
212+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "i686")
213+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") # freebsd
214+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") # windows
215+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86"))
216+
set(PROCESSOR_FAMILY "Intel")
217+
if(CMAKE_COMPILER_IS_GNUCC
218+
OR (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang)
219+
OR (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
220+
OR (CMAKE_CXX_COMPILER_ID STREQUAL Intel))
221+
add_definitions(-march=native)
222+
endif()
223+
endif()
209224
else()
210225
message(STATUS "IPO / LTO not supported: <${error}>")
211226
endif()

0 commit comments

Comments
 (0)