Repository navigation
Description
simd_arm_neon.hpp is referenced by a comment and nothing else
src/platforms/arm/simd_arm_neon.hpp is a full SIMD backend — ~700 lines, the same 66-operation API the other backends implement, using vhaddq_u8, vqmovn_u16 and the rest.
Nothing selects it. src/platforms/simd.h dispatches:
#if x86/x64 -> simd_x86.hpp
#elif FL_IS_ESP32 -> simd_esp32.hpp
#elif __ARM_FEATURE_DSP == 1 -> simd_arm_dsp.hpp
#else -> simd_noop.hppThere is no __ARM_NEON or __aarch64__ arm. __ARM_FEATURE_DSP is the ARMv7E-M DSP extension (Cortex-M4/M7), which ARMv8-A parts do not define, so every ARMv8-A target falls through to the scalar fallback: Apple Silicon, Raspberry Pi 3/4/5, and any ARM64 board.
The only mention of the file outside itself is a comment in simd_arm_dsp.hpp:
// This is the FastLED-wide SIMD API convention (mirrored across simd_noop,
// simd_x86, simd_arm_neon, simd_xtensa, simd_riscv):
Verified with grep -rn simd_arm_neon src ci tests — one hit, that comment.
How this surfaced
While working out why #4285 failed on the macOS CI runner. That PR adds a differential test which includes the fallback under a second namespace to compare it against the host's selected backend; on Apple Silicon the include collapsed, because the fallback was the selected backend and the PCH had already pulled it in.
Why this is not just a missed optimisation
Two consequences beyond speed:
- The macOS CI runner tests the scalar path, not a NEON one. Anyone reading "the ARM SIMD backend is covered by CI" would be wrong.
- The backend is unmaintained by construction. It compiles nowhere, so nothing catches drift in it. It has had no chance to be wrong, and equally no chance to be right.
What would need deciding
Wiring it in is not a one-line change to the dispatch, and I have deliberately not made it:
- Correctness first. test(simd): cover the scalar fallback, and fix three x86 divergences it found (#4216) #4285 lands a differential harness that checks a backend against the fallback across all 66 operations. Pointing that at NEON is the cheap way to find out whether the file is actually correct before it goes live on every ARM64 machine.
- Which guard.
__ARM_NEONis defined on ARMv7-A with NEON as well as ARMv8-A; whether both are wanted is a decision, not a lookup. - Interaction with
__ARM_FEATURE_DSP. A part could define both. The order of the arms then decides which wins, and that should be deliberate. - Blast radius. It changes the compiled code path on Apple Silicon CI and on every Pi-class target at once.
Filed as a finding rather than a fix. Happy to do the wiring once #4285 gives it a check to sit behind, if that is wanted.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Sep 10, 2026
Wired in #4291 — and the first CI run found a real bug in it
The dispatch arm is in that PR, behind the harness this issue said the wiring should sit behind (#4285, now merged). Reporting what it turned up, because it is the answer to "is this backend actually correct?" — which the issue could only pose, not settle.
It was not. macOS CI failed at
tests/fl/math/simd.cpp:298on the first run:blend_u8_16multiplied withvmulq_n_s16.diffspans −255..255 andamountspans 0..255, so the product needs 17 signed bits — at a=0, b=255, amount=192 the true value is 48960, which wraps int16 to −16576, shifts to −65, and saturates to 0 where 191 was wanted. The 25% case immediately above it passed only because 255×64 happens to fit.The scalar fallback never had the bug:
diff * amountpromotes tointthere.Fixed by widening to 32 bits, keeping
vshrn_n_s32so the arithmetic shift the fallback performs is preserved — that matters beyond the overflow, since an arithmetic shift rounds toward negative infinity and a diff of −1 at amount 1 gives −1, not 0. The cheaper absolute-difference form would disagree by one code on every darkening blend.Verified without an ARM machine, two ways: the intrinsic sequence modelled exactly and compared against the fallback across every
amountand a stride over every (a, b) — 109,300 disagreements before, zero after — and cross-compiled with--target=aarch64-linux-gnu -march=armv8-aso the intrinsics are checked by a real ARM front end rather than by eye.The rest of the file was audited for the same class:
scale_u8_16tops out at 255×255 inside auint16and is fine,mullo_u16_8is a wrapping low-half multiply by definition.blend_u8_16was the only one.One thing narrowed rather than fixed
MSVC advertises
_M_ARM64, not__ARM_NEON, so native ARM64 Windows is not covered by the arm — and the_M_ARM64branches already insidesimd_arm_neon.hppstay unreachable there. Nothing regresses (that target took the fallback before too), but I have not added it: there is no MSVC ARM64 runner here, and the case against enabling a backend nobody can check is the bug above. It is pinned by a dispatch case so it reads as a decision.And the dispatch table now has a test
That is the part that keeps this from recurring.
ci/tests/test_simd_dispatch.pyevaluates the real chain with the real preprocessor, one case per target family, and requires everysimd_*.hppin the tree to be reachable. Removing the NEON arm again fails three cases including that one.feat(simd): dispatch ARMv8-A to the NEON backend that was already the…
zackees commentedon Sep 10, 2026
Done in #4291, verified on master, closing
src/platforms/simd.h:56—#include "platforms/arm/simd_arm_neon.hpp"under__ARM_NEON || __ARM_NEON__int16overflow inblend_u8_16is fixed —vmull_n_s16widening atsimd_arm_neon.hpp:157ci/tests/test_simd_dispatch.pyrequires everysimd_*.hppin the tree to be reachable from the chainThe thing worth carrying forward from this issue is what enabling the backend immediately found: a real
int16overflow that had been sitting in the file the whole time it was unreachable — 109,300 disagreements against the scalar fallback across the input space, saturating a 75% blend of black-to-white to 0 instead of 191. A backend nothing compiles is not a backend that works; it is one that has never been asked.Two things deliberately left, both recorded rather than implied:
_M_ARM64rather than__ARM_NEON, so the arm misses it and the_M_ARM64branches inside the backend stay unreachable there. That is the status quo, not a regression, and it is pinned by a case in the dispatch test so whoever adds it changes that case on purpose. There is no MSVC ARM64 runner here, and the overflow above is the argument against enabling a backend nobody can check.__ARM_FEATURE_DSPand__ARM_NEONkeep the DSP backend. Ordering choice, also pinned. Moving them to NEON is likely an improvement with its own targets to check.