Skip to content

Commit 2728515

Browse files
committed
docs: explain why the vector256 overload has no arm64 branch
The two overloads are deliberately asymmetric and it reads as an oversight without a note: Vector256 is never hardware-accelerated on arm64, so nothing there can reach this method and an AdvSimd path would be dead code.
1 parent 645ab0b commit 2728515

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/Base58Encoding/VectorMath.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ internal static Vector256<ulong> MultiplyWidening32(Vector256<ulong> x, Vector25
3232
(y & Vector256.Create(0xFFFFFFFF_00000000UL)) == Vector256<ulong>.Zero,
3333
"MultiplyWidening32 requires both operands < 2^32; a wider value would be silently truncated.");
3434

35+
// No arm64 branch here, unlike the Vector128 overload. Vector256.IsHardwareAccelerated is
36+
// never true on arm64: NEON registers are 128-bit, and SVE is vector-length agnostic so .NET
37+
// exposes it through its own API rather than mapping Vector256 onto it — the Neoverse-N2
38+
// probe reports sve2 in its CPU flags and the JIT still emits only the Vector128 length gate.
39+
// Both callers gate on that property, so arm64 never reaches this width. Note the type itself
40+
// is perfectly usable there; unguarded it would give identical results, just emulated as two
41+
// 128-bit halves. Accelerated or not, an AdvSimd branch here would never execute.
3542
return Avx2.IsSupported ? Avx2.Multiply(x.AsUInt32(), y.AsUInt32()) : x * y;
3643
}
3744

0 commit comments

Comments
 (0)