MCPcopy Create free account
hub / github.com/DLTcollab/sse2neon

github.com/DLTcollab/sse2neon @v1.9.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.9.1 ↗ · + Follow
1,272 symbols 4,870 edges 17 files 599 documented · 47% updated 3mo agov1.9.1 · 2026-01-01★ 1,5178 open issues

Browse by type

Functions 1,254 Types & classes 18
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

sse2neon

GitHub Actions SSE Coverage

A C/C++ header file that converts Intel SSE intrinsics to Arm/Aarch64 NEON intrinsics.

Introduction

sse2neon translates Intel SSE (Streaming SIMD Extensions) intrinsics to Arm NEON, enabling rapid porting of x86 SIMD code to Arm platforms. The header file sse2neon.h provides NEON-based implementations of functions from Intel intrinsic headers (e.g., <xmmintrin.h>), preserving the original semantics.

Mapping and Coverage

Header file Extension
<mmintrin.h> MMX
<xmmintrin.h> SSE
<emmintrin.h> SSE2
<pmmintrin.h> SSE3
<tmmintrin.h> SSSE3
<smmintrin.h> SSE4.1
<nmmintrin.h> SSE4.2
<wmmintrin.h> AES

sse2neon supports SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, and AES extensions.

Some SSE intrinsics map directly to a single NEON intrinsic (e.g., _mm_loadu_si128vld1q_s32), while others require multiple NEON instructions (e.g., _mm_maddubs_epi16 uses 13 instructions).

See perf-tier.md for detailed performance tier classification of all intrinsics.

Floating-point Compatibility

Some conversions produce different results than SSE due to IEEE-754 handling differences.

For example, _mm_rsqrt_ps:

__m128 _mm_rsqrt_ps(__m128 in)
{
    float32x4_t out = vrsqrteq_f32(vreinterpretq_f32_m128(in));

    out = vmulq_f32(
        out, vrsqrtsq_f32(vmulq_f32(vreinterpretq_f32_m128(in), out), out));

    return vreinterpretq_m128_f32(out);
}

This NEON conversion returns NaN for input 0.0 because rsqrt(0) = INF, and the subsequent INF × 0 = NaN. The SSE intrinsic returns INF instead. Enable the compile-time precision flags below when exact SSE compatibility is required.

Requirements

Architecture: Little-endian ARM only. Big-endian ARM is not supported and will produce a compile-time error.

Compilers: | Compiler | Minimum Version | Notes | |----------|-----------------|-------| | GCC | 10+ | Earlier versions have vector instruction bugs | | Clang | 11+ | Earlier versions have vector instruction bugs | | MSVC | 2019+ (v142) | ARM64 and ARM64EC targets supported | | Apple Clang | 12+ | macOS ARM64 (Apple Silicon) |

Earlier GCC/Clang versions contain bugs in vector instruction generation that cause incorrect assembly output for certain NEON intrinsics (e.g., rev16, rev32 with invalid operand combinations).

ARM64EC is a hybrid ABI allowing ARM64 code to interoperate with x64 code.

Usage

  1. Copy sse2neon.h into your source directory.

  2. Replace SSE headers with sse2neon: ```C // Before #include #include

// After #include "sse2neon.h" `` This also replaces{p,t,s,n,w}mmintrin.h`.

  1. Add the appropriate compiler flags: | Target | Compiler Flag | |--------|---------------| | ARMv8-A AArch64 | -march=armv8-a+fp+simd+crypto+crc | | ARMv8-A AArch32 | -mfpu=neon-fp-armv8 | | ARMv7-A | -mfpu=neon |

Remove +crypto and/or +crc if unsupported by your target.

  1. For Windows ARM64EC (hybrid x64/ARM64 mode):
  2. sse2neon.h automatically skips <intrin.h> when _M_ARM64EC is detected
  3. This avoids type conflicts between MSVC's SSE union types and sse2neon's NEON types
  4. No manual configuration needed when using MSVC with ARM64EC target
  5. Note: sse2neon's __m128 type is not ABI-compatible with x64 code; users needing cross-ABI SIMD interop should use MSVC's softintrin instead

  6. (Optional) To reduce the header file size for your specific target architecture and accelerate compilation, you can use the unifdef tool to remove unused conditional compilation paths. For example, to generate a reduced version for AArch64: shell unifdef -DSSE2NEON_ARCH_AARCH64=1 -D__aarch64__=1\ -D__ARM_FEATURE_DIRECTED_ROUNDING=1 -D__ARM_FEATURE_FMA=1 -D__ARM_FEATURE_CRYPTO=1 -D__ARM_FEATURE_CRC32=1 -U__ARM_FEATURE_FRINT\ sse2neon.h > sse2neon_aarch64.h

Compile-time Configurations

NEON trades IEEE-754 compliance for performance when handling denormals and NaNs. Define these macros as 1 before including sse2neon.h to enable precise (but slower) implementations:

Macro Effect
SSE2NEON_PRECISE_MINMAX Correct NaN handling in _mm_min_{ps,pd} and _mm_max_{ps,pd}
SSE2NEON_PRECISE_DIV Extra Newton-Raphson iteration for _mm_rcp_ps and _mm_div_ps
SSE2NEON_PRECISE_SQRT Extra Newton-Raphson iteration for _mm_sqrt_ps and _mm_rsqrt_ps
SSE2NEON_PRECISE_DP Conditional multiplication in _mm_dp_pd
SSE2NEON_UNDEFINED_ZERO Force zero for _mm_undefined_{ps,pd,si128} (MSVC already does this)

All precision flags are disabled by default to maximize performance.

Recommended Flag Combinations by Use Case

Use Case Flags Rationale
Graphics/Rendering MINMAX, SQRT (+DIV if using rcp) NaN handling and normalization; Blender enables all three
DSP/Audio None (defaults) Throughput over precision; inaudible differences
Cryptography None (defaults) Integer-focused; FP precision irrelevant
Scientific/Numerical MINMAX, SQRT, DP Reduces x86 divergence; see caveats below
Game Physics MINMAX Prevents NaN propagation in collision detection
Machine Learning MINMAX for inference NaN handling for determinism; training tolerates defaults

Flags use SSE2NEON_PRECISE_ prefix (e.g., MINMAXSSE2NEON_PRECISE_MINMAX).

Architecture notes: - DIV flag affects _mm_rcp* (reciprocal approximation), not _mm_div* which uses native IEEE-754 division on ARMv8. Enable DIV on ARMv7 or when using reciprocal intrinsics. - For strict determinism, also define SSE2NEON_UNDEFINED_ZERO=1. Some divergences (FTZ/DAZ, NaN payloads) cannot be fully eliminated.

Example configuration for graphics applications:

#define SSE2NEON_PRECISE_MINMAX 1
#define SSE2NEON_PRECISE_SQRT 1
#include "sse2neon.h"

Memory Allocation

Memory from _mm_malloc() must be freed with _mm_free(), not free(). Mixing allocators causes heap corruption on Windows.

MONITOR/MWAIT Policy

ARM has no userspace equivalent for x86 address-range monitoring. _mm_monitor is a no-op; _mm_mwait behavior is controlled by SSE2NEON_MWAIT_POLICY:

Value Behavior
0 (default) yield - Safe everywhere, never blocks
1 wfe - Event wait, may trap in EL0
2 wfi - Interrupt wait, may trap in EL0

Policies 1/2 do not provide "wake on store" semantics and may trap on Linux/iOS/macOS. See sse2neon.h for detailed usage guidance.

Run Built-in Test Suite

Test cases are in the tests directory with runtime-specified input data.

# Basic test run
make check

# Enable crypto and CRC features
make FEATURE=crypto+crc check

# Target specific CPU
make ARCH_CFLAGS="-mcpu=cortex-a53 -mfpu=neon-vfpv4" check

Cross-compilation Testing

Requires QEMU for non-Arm hosts.

# ARMv8-A AArch64
make CROSS_COMPILE=aarch64-linux-gnu- check

# ARMv7-A
make CROSS_COMPILE=arm-linux-gnueabihf- check

# ARMv8-A AArch32
make CROSS_COMPILE=arm-linux-gnueabihf- \
     ARCH_CFLAGS="-mcpu=cortex-a32 -mfpu=neon-fp-armv8" check

See tests/README.md for details.

Optimization Caveats

Compiler optimizations (-O1, -O2, etc.) may cause unexpected behavior with frequent rounding mode changes or repeated _MM_SET_DENORMALS_ZERO_MODE() calls. The project prioritizes performance over these edge cases—developers should handle them explicitly when needed.

Adoptions

Open source projects using sse2neon for Arm/Aarch64 support (partial list): * Aaru Data Preservation Suite is a fully-featured software package to preserve all storage media from the very old to the cutting edge, as well as to give detailed information about any supported image file (whether from Aaru or not) and to extract the files from those images. * aether-game-utils is a collection of cross platform utilities for quickly creating small game prototypes in C++. * ALE, aka Assembly Likelihood Evaluation, is a tool for evaluating accuracy of assemblies without the need of a reference genome. * AnchorWave, Anchored Wavefront Alignment, identifies collinear regions via conserved anchors (full-length CDS and full-length exon have been implemented currently) and breaks collinear regions into shorter fragments, i.e., anchor and inter-anchor intervals. * ATAK-CIV, Android Tactical Assault Kit for Civilian Use, is the official geospatial-temporal and situational awareness tool used by the US Government. * Apache Doris is a Massively Parallel Processing (MPP) based interactive SQL data warehousing for reporting and analysis. * Apache Impala is a lightning-fast, distributed SQL queries for petabytes of data stored in Apache Hadoop clusters. * Apache Kudu completes Hadoop's storage layer to enable fast analytics on fast data. * apollo is a high performance, flexible architecture which accelerates the development of Autonomous Vehicles. * ares is a cross-platform, open source, multi-system emulator, focusing on accuracy and preservation. * ART is an implementation in OCaml of Adaptive Radix Tree (ART). * Async is a set of c++ primitives that allows efficient and rapid development in C++17 on GNU/Linux systems. * avec is a little library for using SIMD instructions on both x86 and Arm. * BARCH is a low-memory, dynamically configurable, constant access time ordered cache similar to Valkey and Redis. * BEAGLE is a high-performance library that can perform the core calculations at the heart of most Bayesian and Maximum Likelihood phylogenetics packages. * BitMagic implements compressed bit-vectors and containers (vectors) based on ideas of bit-slicing transform and Rank-Select compression, offering sets of method to architect your applications to use HPC techniques to save memory (thus be able to fit more data in one compute unit) and improve storage and traffic patterns when storing data vectors and models in files or object stores. * bipartite_motif_finder as known as BMF (Bipartite Motif Finder) is an open source tool for finding co-occurences of sequence motifs in genomic sequences. * Blender is the free and open source 3D creation suite, supporting the entirety of the 3D pipeline. * Boo is a cross-platform windowing and event manager similar to SDL or SFML, with additional 3D rendering functionality. * Brickworks is a music DSP toolkit that supplies with the fundamental building blocks for creating and enhancing audio engines on any platform. * CARTA is a new visualization tool designed for viewing radio astronomy images in CASA, FITS, MIRIAD, and HDF5 formats (using the IDIA custom schema for HDF5). * Catcoon is a feedforward neural network implementation in C. * compute-runtime, the Intel Graphics Compute Runtime for oneAPI Level Zero and OpenCL Driver, provides compute API support (Level Zero, OpenCL) for Intel graphics hardware architectures (HD Graphics, Xe). * contour is a modern and actually fast virtual terminal emulator. * Cog is a free and open source audio player for macOS. * dab-cmdline provides entries for the functionality to handle Digital audio broadcasting (DAB)/DAB+ through some simple calls. * DISTRHO is an open-source project for Cross-Platform Audio Plugins. * Dragonfly is a modern in-memory datastore, fully compatible with Redis and Memcached APIs. * EDGE is an advanced OpenGL source port spawned from the DOOM engine, with focus on easy development and expansion for modders and end-users. * Embree is a collection of high-performance ray tracing kernels. Its target users are graphics application engineers who want to improve the performance of their photo-realistic rendering application by leveraging Embree's performance-optimized ray tracing kernels. * emp-tool aims to provide a benchmark for secure computation and allowing other researchers to experiment and extend. * Exudyn is a C++ based Python library for efficient simulation of flexible multibody dynamics systems. * [FoundationDB](https://www.

Core symbols most depended-on inside this repo

Shape

Function 1,220
Method 34
Class 14
Enum 4

Languages

C++95%
Python5%

Modules by API surface

tests/impl.cpp573 symbols
sse2neon.h505 symbols
scripts/analyze-tiers.py52 symbols
tests/ieee754.cpp31 symbols
tests/fuzz.cpp29 symbols
tests/nan.cpp22 symbols
tests/differential.cpp19 symbols
tests/common.cpp14 symbols
tests/common.h7 symbols
scripts/gen-golden.py5 symbols
scripts/coverage-check.py5 symbols
tests/aes.cpp4 symbols

For agents

$ claude mcp add sse2neon \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page