darmie opened PR #13640 from darmie:aarch64-sdot-relaxed-dot to bytecodealliance:main:
On AArch64 with FEAT_DotProd,
i32x4.relaxed_dot_i8x16_i7x16_add_slowers to a
smull/smull2/addp/saddlp/addwidening chain. This adds ahas_dotprod
setting (auto-detected viacranelift-native) and lowers the op to a single
sdot— the instruction this relaxed op was designed to map to. Without the
feature, the existing fallback is unchanged.There's no dedicated dot CLIF opcode (removed in #5889), so the wasm→CLIF
translator expands the op into aswiden/imul/iadd_pairwise/iaddtree; a
new ISLE rule contracts that tree back intosdot c, a, b.Correctness
sdotis the signed, full-width, no-saturation dot product — exactly the
deterministic CLIF the translator already emits on AArch64 (the x86
pmaddubswpath is gated off here), so this is instruction selection, not a
semantic change. For the in-i7 range the op guarantees, the i16 pair sums
can't overflow, sosdotis bit-identical to the fallback; behavior differs
only in the spec's already-implementation-defined out-of-range zone, and the
relaxed-simd deterministic profile picks the same signed dot. Mirrors the
existingrelaxed_madd→ FMLA pattern of gating a native instruction behind a
feature.Performance
cargo bench --bench relaxed_dot, Apple M1 Pro, wasmtime 47.0.0. The same
module is compiled twice togglinghas_dotprod; the kernel is 8 independent
relaxed-dot accumulator chains (40M i8 4-way dots per call), criterion, 100
samples.
has_dotprodLowering Time / call Speedup falsesmull/smull2/addp/saddlp/add17.12 ms 1.00× truesdot9.32 ms 1.84× Tests / bench
cranelift/filetests/filetests/isa/aarch64/simd-sdot.clif(precise-output lowering).cranelift/filetests/filetests/runtests/simd-sdot.clif(executes the dot via thesdotpath and the fallback across ISAs; results must agree.)tests/disas/aarch64-relaxed-simd-dotprod.wat— golden disas (vs the fallback inaarch64-relaxed-simd.wat).benches/relaxed_dot.rs(the benchmark above)
darmie requested alexcrichton for a review on PR #13640.
darmie requested wasmtime-compiler-reviewers for a review on PR #13640.
darmie requested wasmtime-core-reviewers for a review on PR #13640.
darmie requested wasmtime-default-reviewers for a review on PR #13640.
:memo: alexcrichton submitted PR review:
Thanks for this!
:speech_balloon: alexcrichton created PR review comment:
We don't typically host micro-benchmarks like this for individual instruction/architecture pairs, so it's ok to omit changes here in the
benchesdirectory
:speech_balloon: alexcrichton created PR review comment:
It's ok to drop comments like this, LLMs generate text explaining what a test is but the text becomes irrelevant immediately after landing. This is "just another" test we have and you can leave a comment saying that this is testing the
sdotlowering, but no need to call it a "new" lowering since after this PR merges that's stale text.
:speech_balloon: alexcrichton created PR review comment:
Could this include a
test interpretas well to verify it runs against the interpreter?
:memo: darmie submitted PR review.
:speech_balloon: darmie created PR review comment:
Okay 👍🏾. Noted for next time. I'll make the change.
:speech_balloon: darmie created PR review comment:
Resolved.
:speech_balloon: darmie created PR review comment:
Done! It passes.
darmie updated PR #13640.
:memo: darmie submitted PR review.
:memo: darmie submitted PR review.
:speech_balloon: darmie created PR review comment:
Removed!
darmie requested alexcrichton for a review on PR #13640.
:memo: darmie submitted PR review.
:thumbs_up: alexcrichton submitted PR review.
alexcrichton added PR #13640 cranelift(aarch64): lower the i8 relaxed dot product to NEON SDOT to the merge queue.
:check: alexcrichton merged PR #13640.
alexcrichton removed PR #13640 cranelift(aarch64): lower the i8 relaxed dot product to NEON SDOT from the merge queue.
Last updated: Jul 29 2026 at 05:03 UTC