qualcomm/easywos/sse-avx-to-neon
Claude Code and agent skill by qualcomm/easywos
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Port x86 SSE/AVX intrinsics to ARM NEON, including CRC32 PCLMULQDQ → PMULL. Use when translating x86/x64 intrinsic code to NEON equivalents, adding ARM paths alongside existing x86 code, writing ARM NEON compute kernels from SSE/AVX specifications, or porting PCLMULQDQ-based CRC32 to PMULL. Triggers on: port SSE to NEON, add ARM NEON path, translate AVX to NEON, port CRC32 to ARM, intrinsic names like _mm_add_epi32 / _mm256_sub_ps / _mm_load_si128 / _mm_clmulepi64_si128, __m128i, __m256i, vmull_p64, ARM_PMULL, or any task involving mapping x86 vector intrinsics to ARM NEON.
Install
npx vskill@latest install qualcomm/easywos/sse-avx-to-neonSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as qualcomm/easywos/sse-avx-to-neon.
SSE/AVX → ARM NEON Porting Guide
Platform Guard Pattern
Standard structure for adding a NEON path alongside existing x86 code:
Project wrapper headers: If the project has its own NEON header (e.g., neon_intrins.h in zlib-ng), include that instead of <arm_neon.h> directly. Project wrappers handle compiler portability (MSVC vs GCC), define convenience macros like vqsubq_u16_x4_x1, and extend standard intrinsics with alignment-hint variants (_ex suffix). Always check for a project-level NEON header before reaching for the system one.
Type Selection
__m128i is a generic 128-bit container. The NEON type's width comes from the intrinsic suffix (_epi32 → 32-bit), but its signedness does not — read signedness from the op and the data, not the suffix (see below).
Signedness only matters for a minority of ops — and the SSE suffix usually doesn't encode it.Most integer SSE intrinsics carry_epiNregardless of whether the data is logicallysigned (_mm_add_epi32,_mm_loadu_si128,_mm_and_si128,_mm_slli_epi16); a true_epusuffix appears only on a few ops (_mm_min_epu8,_mm_max_epu16,_mm_subs_epu8, …).So:- Add/sub, bitwise, load/store, immediate shift are sign-agnostic —veorq_s32≡veorq_u32. Pick either; match the width only.- Signedness is mandatory for: compares (vcgtq_s32vsvcgtq_u32), min/max, arithmetic vs logical right shift (vshrq_n_svsvshrq_n_u), and saturating widen/narrow (vqmovnvsvqmovun). Choosing wrong here silently produces incorrect results — read the data's signedness from context, not from the suffix.
How to pick — in order:
- Does the op care about signedness? Add/sub, bitwise, load/store, immediate left shift → no. Pick
sorufreely (match the surrounding code), get the width right, done. - If it's a sign-sensitive op, copy the choice x86 already made — the source author was forced to pick too:
_mm_cmpgt_epi32→ signed (vcgtq_s32);_mm_min_epu8→ unsigned (vminq_u8);_mm_srli(logical) →vshrq_n_u;_mm_srai(arithmetic) →vshrq_n_s. - If the op doesn't disambiguate, follow the variable's C type (
uint8_t*→u8,int16_t*→s16), then the data's format/semantics (luma is unsigned; 16-bit PCM is signed; 8-bit WAV is unsigned).
Why step 2/3 matter — the same bits shifted right one place:
Both compile, neither warns; only the data's true signedness says which is correct.
| SSE suffix / type | NEON type | Element | |
|---|---|---|---|
_epi8 / __m128i | int8x16_t | signed 8-bit | |
_epi16 / __m128i | int16x8_t | signed 16-bit | |
_epi32 / __m128i | int32x4_t | signed 32-bit | |
_epi64 / __m128i | int64x2_t | signed 64-bit | |
_epu8 / __m128i | uint8x16_t | unsigned 8-bit | |
_epu16 / __m128i | uint16x8_t | unsigned 16-bit | |
_epu32 / __m128i | uint32x4_t | unsigned 32-bit | |
_epu64 / __m128i | uint64x2_t | unsigned 64-bit | |
_ps / __m128 | float32x4_t | 32-bit float | |
_pd / __m128d | float64x2_t | 64-bit float (AArch64 only) |
64-bit half-width (D-register) types. Widening and narrowing ops take or produce 64-bit halves, not full 128-bit vectors. vmovl_u8 (8→16 widen) takes a uint8x8_t; vmull_s16 takes two int16x4_t and yields int32x4_t; vget_low_* / vget_high_* and any MMX __m64 port also land on these. Same naming, half the lanes:
| Full (Q-reg, 128-bit) | Half (D-reg, 64-bit) | |
|---|---|---|
int8x16_t / uint8x16_t | int8x8_t / uint8x8_t | |
int16x8_t / uint16x8_t | int16x4_t / uint16x4_t | |
int32x4_t / uint32x4_t | int32x2_t / uint32x2_t | |
float32x4_t | float32x2_t |
Polynomial types are required for carryless multiply / CRC work (see the PCLMULQDQ → PMULL section): poly8x16_t, poly16x8_t, poly64x2_t, and the scalar poly128_t result of vmull_p64. Use vreinterpretq_u8_p128(...) to get back to a byte vector.
For reinterpretation between types (e.g., treating float32x4_t as uint32x4_t for bitwise ops), use vreinterpretq_<dst>_<src>().
For operations that mix input/output types (pack, unpack, cvt), choose the NEON type matching the output element type.
AVX-512 (512-bit) Decomposition
NEON has no 512-bit registers. Each _mm512_* op decomposes into four independent 128-bit NEON ops, mirroring the AVX-256 → NEON pattern but with four halves instead of two. Several AVX-512 features go beyond width and need NEON-specific recipes: __mmaskN mask types (replace with plain uintNN_t), masked load/store (no NEON equivalent — use scalar tail or vbslq_u8 blend), compare-to-bitmask (vshrn_n_u16(_, 4) packer), full-vector horizontal reductions (4-way tree + vXXXvq_*), SAD / maddubs / madd / VNNI dot products, four-lane CLMUL, and cross-lane permutes (vqtbl4q_u8, AArch64-only).
See avx512-decomposition.md for the full recipe set covering load/store split, element-wise decomposition, constants & casts, lane extract/insert, mask types, masked load/store, compare-to-bitmask, horizontal reductions, SAD/maddubs/madd/VNNI, CLMUL (_mm512_clmulepi64_epi128 → 4× vmull_p64), and cross-lane permute / shuffle / ternarylogic.
AVX 256-bit Decomposition
NEON has no 256-bit registers. Split __m256* into two 128-bit halves and apply the SSE equivalent to each:
When the codebase wraps __m256i in a struct, extract halves via pointer cast:
See avx-decomposition.md for cross-lane operations (permute, broadcast, extract/insert).
Prefer xN Struct Loads for Memory-Bound Loops
When porting a loop that applies a uniform operation (e.g., saturating subtract) across a large array, using _x4 struct loads/stores is better than 4 individual vld1q calls — it gives the compiler and hardware more context to optimise memory access:
If the project wrapper defines _ex alignment-hint variants, add the alignment:
The 256 is the alignment in bits; the hint lets the microarchitecture use wider memory bus transactions. Only use it when the pointer is actually aligned to that boundary.
Loop direction: Iterate forward through the array (increment table += N), not backward. Mirroring x86 backward iteration adds complexity with no ARM benefit and prevents the hardware prefetcher from recognising the sequential access pattern.
Broadcast inside, not outside: Pass the scalar value to the inner function and call vdupq_n_u16 there, rather than pre-building the broadcast vector in the caller and passing uint16x8_t. This keeps the API simple and matches idiomatic ARM NEON style:
PCLMULQDQ → PMULL (CRC32)
First decide the algorithm, then translate. A line-for-line PCLMULQDQ→PMULL portis usually not the fastest ARM CRC and measured 0.30× of upstream on zlib-ng.Unlike x86, AArch64 has a hardware CRC32 instruction (__crc32b/h/w/d, feature+crc) on a separate execution port from PMULL. The upstream-class kernel runsscalar hardware-CRC lanes in parallel with wide PMULL folding (e.g. 9-way fold +3-way__crc32d, 192 B/iter,EOR3-combined). If the target has+crc, write thathybrid as the primary kernel — do not transliterate the x86 fold. See the"Choosing the ARM algorithm" section of crc32-pmull.md before writing any code.
For the fold mechanics: _mm_clmulepi64_si128 maps to vmull_p64 / vmull_high_p64 from <arm_neon.h> (feature guard: __ARM_FEATURE_PMULL). Note the header split — the PMULL intrinsics are in <arm_neon.h>, while the scalar hardware-CRC intrinsics (__crc32b/h/w/d) used by the +crc kernel live in <arm_acle.h>; this section uses both. The result is poly128_t; reinterpret back with vreinterpretq_u8_p128(...). Each of the four imm8 lane-select variants maps to a different vgetq_lane_p64 / vmull_high_p64 combination — define named clmul_lo_lo / clmul_hi_lo / clmul_lo_hi / clmul_hi_hi macros rather than inlining the reinterpret chain. Use EOR3 (veor3q_u64, feature __ARM_FEATURE_SHA3) to fuse the two fold XORs plus the new data load into one instruction.
See crc32-pmull.md for the algorithm-choice decision rule, the hardware-CRC baseline (+crc variant) kernel, macros, _mm_set_epi32 / _mm_shuffle_epi8 / _mm_blend_epi16 replacements, polynomial constants, fold-state patterns, Chorba algorithm, and Barrett reduction.
Common Intrinsic Mappings
See type-mappings.md for comprehensive tables.
Quick reference for the most frequent operations:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingagent/skills/sse-avx-to-neon/SKILL.md
Popularity
- Repository stars
- 2
- Repository forks
- 1
- 7-day trend score
- 5
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/qualcomm/easywos/sse-avx-to-neon)