NicolasStigler removed the review request for wasmtime-compiler-reviewers from PR #15158.
NicolasStigler opened PR #15158 from NicolasStigler:main to bytecodealliance:main.
NicolasStigler requested cfallin for a review on PR #15158.
NicolasStigler requested wasmtime-compiler-reviewers for a review on PR #15158.
NicolasStigler edited PR #15158:
Fixes #3295
Why
The x64 backend had no lowering for
sadd_satoni32x4ori64x2. Since x86 has no packed signed saturating-add instruction for those lane widths and there was no legalization fallback, these operations failed with an ISLE lowering error.What changed
- Add SSE2-based lowerings for
i32x4andi64x2signed saturating addition.- Detect signed overflow per lane and select the appropriate
MINorMAXsaturation value.- Update x64 fuzzgen so it no longer excludes
sadd_satfor these types.- Add an x64 regression test covering overflow, boundary values, and non-overflowing lanes on baseline and AVX targets.
Testing
cargo +1.97.0 fmt --all -- --checkcargo +1.97.0 test -p cranelift-codegencargo +1.97.0 test -p cranelift-filetestscargo +1.97.0 test -p cranelift-tools --test filetestscargo +1.97.0 test -p cranelift-tools --test logged-filetestscargo +1.97.0 test -p cranelift-fuzzgencargo +1.97.0 check -p cranelift-fuzzgen- Ran the regression test and issue reproducer with
clif-util; both passed.- Ran an additional generated stress test with 400 random cases for each vector type and all
i64x2boundary pairs; all passed natively.- Compile-checked AVX and AVX-512 targets. The AVX runtime variant ran on the host; AVX-512 was compile-checked only.
if everything looks fine ill proceed with #3296
github-actions[bot] added the label cranelift:area:x64 on PR #15158.
github-actions[bot] added the label cranelift on PR #15158.
:thumbs_up: cfallin submitted PR review:
Thanks! Looks good -- just one question about the test below.
:speech_balloon: cfallin created PR review comment:
Is this supported on any of our other architectures? Let's add any that also work here to maximize coverage.
NicolasStigler updated PR #15158.
:memo: NicolasStigler submitted PR review.
:speech_balloon: NicolasStigler created PR review comment:
Yes, aarch64 and riscv64+V support both
i32x4andi64x2, so I added those targets (including thehas_c/has_zcbvariants) and renamed the test tosimd-saddsat-wide.clif(changed the name since now its not only x64). s390x only supportsi32x4(its lowering saysi64x2is unsupported) and Pulley only hasi8x16/i16x8, so those aren’t included. Cross-compile checks pass for aarch64 and both riscv64 configurations, andcargo +1.97.0 test -p cranelift-tools --test filetestspasses.
:speech_balloon: NicolasStigler edited PR review comment.
cfallin has enabled auto merge for PR #15158.
cfallin added PR #15158 cranelift: x64: implement packed signed saturating addition - #3295 to the merge queue.
alexcrichton removed PR #15158 cranelift: x64: implement packed signed saturating addition - #3295 from the merge queue.
alexcrichton added PR #15158 cranelift: x64: implement packed signed saturating addition - #3295 to the merge queue.
:check: alexcrichton merged PR #15158.
alexcrichton removed PR #15158 cranelift: x64: implement packed signed saturating addition - #3295 from the merge queue.
Last updated: Nov 19 2026 at 20:05 UTC