You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
batch_cast<int64_t>(batch<double>) fell back to a scalar loop through a stack
buffer on every architecture without a native instruction. Split trunc(x) into
hi * 2^32 + lo and read each half out of the mantissa with the 1.5 * 2^52 magic
constant: both halves are small enough that the add is exact, so the result is
independent of the rounding mode.
Selected on sse2, sse4.1, avx, avx2, avx512f-without-DQ, vsx, vxe and wasm.
avx512dq keeps vcvttpd2qq, neon64, sve, rvv and emulated keep their own.
ns/element on a 128 KB L2-resident loop (Xeon w5-3435X, gcc 13.3 -O3, min of
300 reps, interleaved):
sse2 2.387 -> 1.896 1.26x
sse4.1 2.332 -> 0.636 3.67x
avx 1.221 -> 0.501 2.44x
avx2 1.221 -> 0.289 4.22x
avx512f 0.697 -> 0.206 3.38x
The unchanged int64 -> double control arm moves by at most 13%.
test_cast_all_lanes covers float -> int32 and double -> int64 with a different
value in every lane; the other cast tests are splats that only inspect lane 0.
Assisted-by: Claude Opus 5 <noreply@anthropic.com>
0 commit comments