Skip to content

Commit

Permalink
archs: MSVC 2013 and greater don't have a SSE flag
Browse files Browse the repository at this point in the history
But still they support SSE built-in.
Add FORCE_ARCH macro to enable SIMD architecture for
compilers which don't have a compiler flag to check
for them.
  • Loading branch information
noc0lour committed Nov 9, 2020
1 parent 24c7c84 commit 23d5871
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 0 additions & 3 deletions gen/archs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<check name="mmx"></check>
<flag compiler="gnu">-mmmx</flag>
<flag compiler="clang">-mmmx</flag>
<flag compiler="msvc">/arch:SSE</flag>
<alignment>8</alignment>
</arch>

Expand All @@ -82,7 +81,6 @@
<check name="sse"></check>
<flag compiler="gnu">-msse</flag>
<flag compiler="clang">-msse</flag>
<flag compiler="msvc">/arch:SSE</flag>
<environment>_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);</environment>
<include>xmmintrin.h</include>
<alignment>16</alignment>
Expand All @@ -92,7 +90,6 @@
<check name="sse2"></check>
<flag compiler="gnu">-msse2</flag>
<flag compiler="clang">-msse2</flag>
<flag compiler="msvc">/arch:SSE2</flag>
<alignment>16</alignment>
</arch>

Expand Down
15 changes: 11 additions & 4 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ macro(OVERRULE_ARCH arch reason)
list(REMOVE_ITEM available_archs ${arch})
endmacro(OVERRULE_ARCH)

macro(FORCE_ARCH arch reason)
message(STATUS "${reason}, Forced arch ${arch}")
list(APPEND available_archs ${arch})
endmacro(FORCE_ARCH)

########################################################################
# eliminate AVX on if not on x86, or if the compiler does not accept
# the xgetbv instruction, or {if not cross-compiling and the xgetbv
Expand Down Expand Up @@ -257,13 +262,15 @@ if(NOT CROSSCOMPILE_MULTILIB AND CPU_IS_x86)
endif()

#MSVC 64 bit does not have MMX, overrule it
if (${SIZEOF_CPU} EQUAL 64 AND MSVC)
if (MSVC)
if (${SIZEOF_CPU} EQUAL 64)
OVERRULE_ARCH(mmx "No MMX for Win64")
if (MSVC_VERSION GREATER 1700)
OVERRULE_ARCH(sse "No SSE for Win64 Visual Studio 2013")
endif()
endif()
FORCE_ARCH(sse "Built-in for MSVC > 2013")
FORCE_ARCH(sse2 "Built-in for MSVC > 2013")
endif()


endif()

########################################################################
Expand Down

0 comments on commit 23d5871

Please sign in to comment.