MSVC opt /fp:fast /Oi, intrinsic sqrt() w/ XBRZ.
For MSVC, add the optimization flags: /fp:fast /Oi , to favor speed for floating point operations and use intrinsic operations where possible. For release builds also add: /O2 . Use sqrt() instead of std::sqrt() in XBRZ for MSVC x64 just in case to make sure it uses the intrinsic version. Test build is reported to run much faster. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
2eb45cd967
commit
73223445d6
|
@ -744,12 +744,12 @@ elseif(MSVC)
|
|||
string(REGEX REPLACE "/[Ww][^ ]+" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
string(REGEX REPLACE "/[Ww][^ ]+" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
add_compile_options(/std:c++17 -D__STDC_LIMIT_MACROS)
|
||||
add_compile_options(/std:c++17 -D__STDC_LIMIT_MACROS /fp:fast /Oi)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
add_compile_options(/W4)
|
||||
else()
|
||||
add_compile_options(/w)
|
||||
add_compile_options(/w /O2)
|
||||
|
||||
if(ENABLE_LTO)
|
||||
add_compile_options(/GL)
|
||||
|
|
|
@ -76,8 +76,10 @@ inline double fastSqrt(double n)
|
|||
fld n
|
||||
fsqrt
|
||||
}
|
||||
#else // defined(_MSC_VER) && defined(_M_X64) OR other platforms
|
||||
// VisualStudio x86_64 does not allow inline ASM
|
||||
#elif defined(_MSC_VER)
|
||||
// On MSVC x64 use intrinsic with /Oi and /fp:fast
|
||||
return sqrt(n);
|
||||
#else // Other platforms.
|
||||
return std::sqrt(n);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue