Skip to content

Allow setting XSIMD_WITH_SSE3, SSSE3, SSE4_1 and SSE4_2 manually with MSVC - #1430

Merged
JohanMabille merged 1 commit into
xtensor-stack:masterfrom
kou:sse-msvc
Oct 16, 2026
Merged

JohanMabille merged 1 commit into
xtensor-stack:masterfrom
kou:sse-msvc

Conversation

@kou

@kou kou commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

MSVC doesn't define __SSE3__, __SSSE3__, __SSE4_1__ or __SSE4_2__ even with /arch:SSE4.2. So users need to define these reserved identifiers to enable these instruction sets with MSVC since #881. But defining them may break other libraries. For example, simdjson >= 5 uses GCC builtins such as __builtin_ctz when __SSE2__ is defined: apache/arrow#51690

This allows users to set XSIMD_WITH_SSE3, XSIMD_WITH_SSSE3, XSIMD_WITH_SSE4_1 and XSIMD_WITH_SSE4_2 manually only with MSVC. For example, users can enable SSE4.2 with MSVC by -DXSIMD_WITH_SSE4_2=1. Lower instruction sets are enabled automatically by the existing MSVC workaround. This also allows selecting SSE3 or SSSE3 with MSVC requested in #878.

Other compilers including clang-cl define these macros based on compiler flags and require the corresponding compiler flags to use intrinsics. So setting them manually with other compilers is reported as an error.

… MSVC

MSVC doesn't define __SSE3__, __SSSE3__, __SSE4_1__ or __SSE4_2__ even
with /arch:SSE4.2. So users need to define these reserved identifiers
to enable these instruction sets with MSVC since xtensor-stack#881. But defining
them may break other libraries. For example, simdjson >= 5 uses GCC
builtins such as __builtin_ctz when __SSE2__ is defined:
apache/arrow#51690

This allows users to set XSIMD_WITH_SSE3, XSIMD_WITH_SSSE3,
XSIMD_WITH_SSE4_1 and XSIMD_WITH_SSE4_2 manually only with MSVC. For
example, users can enable SSE4.2 with MSVC by -DXSIMD_WITH_SSE4_2=1.
Lower instruction sets are enabled automatically by the existing MSVC
workaround. This also allows selecting SSE3 or SSSE3 with MSVC
requested in xtensor-stack#878.

Other compilers including clang-cl define these macros based on
compiler flags and require the corresponding compiler flags to use
intrinsics. So setting them manually with other compilers is reported
as an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kou

kou commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Apache Arrow needs only XSIMD_WITH_SSE4_2 but this also includes XSIMD_WITH_SSE3, XSIMD_WITH_SSSE3 and XSIMD_WITH_SSE4_1 for consistency. If we don't need XSIMD_WITH_SSE3, XSIMD_WITH_SSSE3 and XSIMD_WITH_SSE4_1, I can remove them from this PR.

@JohanMabille

Copy link
Copy Markdown
Member

Thanks!

@JohanMabille
JohanMabille merged commit f92d002 into xtensor-stack:master Oct 16, 2026
105 of 107 checks passed
@kou
kou deleted the sse-msvc branch October 16, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants