visual-c++ssesimdsse4

How do I enable SSE4.1 and SSE3 (but NOT AVX) in MSVC


I am trying to enable different simd support using MSVC.

There is a page talking about enabling some simd, such as SSE2, AVX, AVX2 https://learn.microsoft.com/en-us/cpp/build/reference/arch-x86?redirectedfrom=MSDN&view=vs-2019

However, it does not mention how to enable other simd optimizations, e.g., SSE4.1, SSE4.2, SSE3 Is it possible to enable these without enabling AVX?

Also, looks like in MSVC2017 /arch:SSE2 is no longer supported/needed, can I assume that SSE3/SSE4.1/SSE4.2 are enabled by default as well?


Solution

  • Apparently you can pass /arch: options in undocumented way as /d2... options. Like /d2archAVX.

    /d2archSSE42 is accepted this way (but not SSE41 or SSE3).

    @Peter pointed out in a comment a case where /d2archSSE42 makes difference: https://godbolt.org/z/EsjW4vTne