Skip to content

Commit 3a12375

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 214216e commit 3a12375

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
@@ -202,6 +202,21 @@ if(ipo_supported)
202202
message(STATUS "IPO / LTO enabled")
203203
set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
204204
add_definitions(-DLTO)
205+
if ((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
206+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
207+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "i586")
208+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "i686")
209+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") # freebsd
210+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") # windows
211+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86"))
212+
set(PROCESSOR_FAMILY "Intel")
213+
if(CMAKE_COMPILER_IS_GNUCC
214+
OR (CMAKE_C_COMPILER_ID STREQUAL AppleClang)
215+
OR (CMAKE_C_COMPILER_ID STREQUAL Clang)
216+
OR (CMAKE_C_COMPILER_ID STREQUAL Intel))
217+
add_definitions(-march=native)
218+
endif()
219+
endif()
205220
else()
206221
message(STATUS "IPO / LTO not supported: <${error}>")
207222
endif()

0 commit comments

Comments
 (0)